Classloading in JLense

Classloading in Eclipse and JLense can be confusing for developers that are not used to working within a container that handles classloading for them. For instance, most web application developers that deploy thier applications inside a servlet engine are used to having the servlet engine manage all classloading. By contrast, most Swing developers are used to controlling the classpath themselves.

An Eclipse application is composed entirely of plugins. The Eclipse runtime engine manages classloading for each plugin. Therefore, the only classes that are visible to a plugin are those classes which the Eclipse runtime engine makes visible to the plugin.

The only way to make classes visible to a plugin is to configure the plugin manifest file to include an <import> tag for the classes it requires in the <requires> section of the plugin manifest. See this article on the plugin manifest for more information on how to configure a plugin so that the classes it requires are available to it.

JLense Classloading Best Practices

Most Eclipse plugins contain a jar file that contains all of the plugin's classes. A corresponding <library> tag that specifies the jar file is included in the <runtime> section of the plugin's manifest. One thing that developers may notice about JLense is that the JLense and JLedger plugins do not package thier classes into jar files. JLense and JLedger plugin directories contain a classes directory that contains the plugin's classes. The reason for this is that it is much more convenient to develop plugins with this configuration.

This is the typical code/compile/debug cycle when plugins include a jar file in thier plugin directory...

  1. make a code change
  2. recompile your code
  3. rebuild plugin class jar files
  4. start your application
  5. debug your application
Typically, step 3 requires you to leave your IDE and use a build script to get your jar files rebuilt.

By putting all classes into a classes directory the code/compile/debug is shortened to this..

  1. make a code change
  2. recompile your code
  3. start your application
  4. debug your application
It is usually possible to configure whatever IDE you use to recompile classes directly to the plugin's classes directory. Therefore you never have to leave your IDE. This makes the code/compile/debug cycle much faster.

When using an IDE like Eclipse that can hot-swap code the code/compile/debug cycle becomes even shorter...

  1. make a code change
  2. recompile your code
  3. debug your application