Login  Register

Re: ImageJ Applet and Macros

Posted by StrongSteve on Feb 02, 2008; 4:27pm
URL: http://imagej.273.s1.nabble.com/ImageJ-Applet-and-Macros-tp3697304p3697308.html

Thanks again, but now I have found the root the problem. Unfortunately i do not know an answer yet. any ideas?

Till now I have developed a simple Java Applet (mostly with ImageJ files) that is being packed in a signed jar-file and has the following structure:

{code}
-edu
³   -ucla
³       -alger
³           -wlmacro
-ij
³   -gui
³   -io
³   -macro
³   -measure
³   -plugin
³   ³   -filter
³   ³   -frame
³   -process
³   -text
³   -util
-macros
-META-INF
-plugins
{code}

Now I have a very tricky problem, I can not solve. Inside the Funtions.class located in the package ij.macro is this statement:

{code}
ClassLoader.getSystemClassLoader().loadClass("edu.ucla.alger.wlmacro.WindowLevelMacro");
{code}

Whenever I execute this statement the follwing stacktrace appears in the Java Console (from IE).

{code}
java.lang.ClassNotFoundException: edu.ucla.alger.wlmacro.WindowLevelMacro
                at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at ij.macro.Functions.call(Functions.java:3090)
        at ij.macro.Functions.getStringFunction(Functions.java:233)
        at ij.macro.Interpreter.getStringTerm(Interpreter.java:1134)
        at ij.macro.Interpreter.getString(Interpreter.java:1109)
        at ij.macro.Interpreter.doStatement(Interpreter.java:263)
        at ij.macro.Interpreter.doBlock(Interpreter.java:540)
        at ij.macro.Interpreter.runMacro(Interpreter.java:123)
        at ij.macro.MacroRunner.run(MacroRunner.java:112)
        at java.lang.Thread.run(Unknown Source)
{code}

Nevertheless the statement below executes without any problems. (I just wanted to try if class loading is possible from applets in general.)

{code}
ClassLoader.getSystemClassLoader().loadClass("java.net.URL");
{code}

So I think the problem is, that the class loader searches in a wrong classpath. It does find classes from the Java distribution but not from - or within - my applet jar-file.

How can I solve this problem?

Thanks a lot in advance!

Greetings
Stefan

Sami Badawi-2 wrote
Hi Stefan,

Sorry I did not follow the link to Window Level Macro page.
It turns out that you also need to have a jar file loaded: windowLevelMacro.jar
You need to set the path for that in the html applet tag

Another thing that I found very useful when doing applet development was to
actually debug the applet, I got that to work from both JBuilder and
Eclipse. It is very easy to set up here is a link:

http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/debugger.html

-Sami Badawi
http://www.shapelogic.org