Login  Register

Just another CLASSPATH problem

Posted by Joachim Wesner on Jan 01, 2008; 12:40pm
URL: http://imagej.273.s1.nabble.com/Superimpose-tp3697641p3697643.html

Hi all, best wishes for the new year!

I know this subject has been discussed quite for some time, but I think I
probably stumbled over some other  "feature" that I did not yet find
discussed!?

Scenario:

1) I´m working on some small to medium size plugins using the IJ built-in
Editor and Compile-and-Run commands.
2) While development the source files for the plugin are stored in a
subdirectory of /plugins
3) I have a couple of utility classes that are packaged together in
*another* subdirectory of /plugins, say /plugins/libs as a simple example.
This is because several plugins will later need to access those classes. I
also do not really like to have a hidden copy of the utility classes with
evey plugin in the jar as discussed in some posts.
4) While working on a plugin I also might want to have easy access to the
source code of the utility classes for fixes, adding extra methods etc.,
i.e. I want to keep the classes resp. java sources
in its subdirectory, not in a .jar file
5) However, when later deploying the plugin, I do not want to make any
changes on the source code, i.e. no changes on "import libs.*" or "package"
statements. At best both subdirecties would simply need to be converted to
.jar files that both go into /plugins and it should work.

As I understand from studying the different posts in this forum and infos
on the internet, there is no problem for this setup at *RUN* time, but it
is a problem at *COMPILE* time. This is because ImageJ
has its own class loader which is smarter than the regular Jdk loader, i.e.
it will treat .jars exactly like subdirectories, so the above mentioned
final conversion from subdirectory to .jar requires
no changes. However, at compile time the regular Java loader is active,
which does not  act this way,

The problem:

One suggestion to fix this is to simply add the /plugins directory to the
IJ class path. I did this in the ImageJ.cfg file. After this, everything
works fine as long as the plugin sources really are in a
subdirectory of /plugins as mentioned above, but I just discovered a
strange behaviour when you try to create a simple plugin in /plugins
itself, for example using the "Plugins/New/Plugin/OK/^R" command. Everyting
seems to run OK, the message box of My_Plugin.java appears, but after this,
you cannot really do any changes to the source file (I.e. change the text
in the message box), any changes will be ignored, it seems some hidden,
cached version of that class is running, also even deleting the
MyPlugin.class does not help, you need to restart ImageJ to see any
changes.

This strange behavious disappears when you either put the simple plugin in
its own subdirectory of remove /plugins again from the classpath in
ImageJ.cfg

I tried IJ 1.39k or 1.39n with package Java 1.6.0._02 (Win XP)

Any suggestions?

Sincerely

Mit freundlichen Grüßen / Best regards

Joachim Wesner

____________________________________________

Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
Wetzlar  HRB 2432
Geschäftsführer: Dr. Martin Haase | Colin Davis | Dr. Wolf-Otto Reuter


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________