Login  Register

Re: ImageJ startup and CLASSPATH

Posted by Johannes Hermen on Nov 04, 2005; 9:57am
URL: http://imagej.273.s1.nabble.com/ImageJ-startup-and-CLASSPATH-tp3704542p3704544.html

Hi Wayne

ImageJ Interest Group <[hidden email]> wrote on 03.11.2005 16:33:56:
> There is no need for another starter application. Try adding the JAR
> files to the ImageJ plugins directory, or sub-directory. ImageJ's
> PluginClassLoader can load classes from JAR files located in the
> plugins directory.

I just tried it that way, but i get a "class not found" Exception from
inside one of my used external libraries.
This is the part of the code that throws the Exception:
---------
public static Object findFactory(String key) {
        ClassLoader loader =
Thread.currentThread().getContextClassLoader();
        String name = rb.getString(key);
        try {
            return loader.loadClass(name).newInstance();
        } catch (ClassNotFoundException ex) {
            throw new ConfigurationError("class not found: " + name, ex);
        } catch (InstantiationException ex) {
            throw new ConfigurationError("could not instantiate: " + name,
ex);
        } catch (IllegalAccessException ex) {
            throw new ConfigurationError("could not instantiate: " + name,
ex);
        }
   }
---------
could this be a problem with your classloader, because it works if the
libraries are in the normal java CLASSPATH?

It would be really cool if this solution would work.

>If that doesn't work, try adding the JAR files to
> Java extension directory, ..\ImageJ\jre\lib\ext on Windows and Linux,
> or /System/Library/Java/Extensions on Mac OS X.

This solution works, but is not really an option to us. Some of our users
work on Linux and Windows systems without admin-rights and are unable to
place the files in the extension directory. Another problem is that this
solution makes it impiossible to have different versions of the same
libraries for different applications.


Thanks for your help

        Johannes Hermen