Login  Register

ImageJ Plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

ImageJ Plugin

Hao An
Hi,

I am working on create my plugins. But I keep getting following error
message:

Plugin or class not found: "My_Plugin"
(java.lang.NoClassDefFoundError: My_Plugin(wrong
name:plugins/My_Plugin))

But I am sure I put My_Plugin.java and My_Plugin.class under plugins
fold.

So how do you guys make your plugins work. Do I need to add something in
build.xml for ant?

Thanks so much.

Hao
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: ImageJ Plugin

dscho
Hi,

On Tue, 6 Feb 2007, Hao An wrote:

> I am working on create my plugins. But I keep getting following error
> message:
>
> Plugin or class not found: "My_Plugin"
> (java.lang.NoClassDefFoundError: My_Plugin(wrong
> name:plugins/My_Plugin))
>
> But I am sure I put My_Plugin.java and My_Plugin.class under plugins
> fold.

I answered a similar question recently:

http://article.gmane.org/gmane.comp.java.imagej/6992

The problem is that unless you package the class files, you _must not_ put
the class into a package. In other words, if you remove the line

        package plugins;

from your java file, it will start to work.

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: ImageJ Plugin

Hao An
In reply to this post by Hao An
I do not have the line of "package plugins".

I noticed that My_Plugin works for my installed imageJ1.37v, but not for
the one generated from source code by ant run.  When I click
Plugins>Compile and Run.  It gave me that:

This JVM does not include the javac compiler. Javac is included with the
Windows and Linux versions of ImageJ that are bundled with Java.

I wrote the macro(write(call("java.lang.System.getProperty",
"java.home")), and I got this

C:\Program Files\java\jdk1.5.0_04\jre

That looks fine to me.

But why Plugins>Compile and Run not work for ant-built ImageJ.

Many thanks.

Hao





-----Original Message-----
From: Johannes Schindelin [mailto:[hidden email]]
Sent: Tuesday, February 06, 2007 4:23 PM
To: Hao An
Cc: [hidden email]
Subject: Re: ImageJ Plugin

Hi,

On Tue, 6 Feb 2007, Hao An wrote:

> I am working on create my plugins. But I keep getting following error
> message:
>
> Plugin or class not found: "My_Plugin"
> (java.lang.NoClassDefFoundError: My_Plugin(wrong
> name:plugins/My_Plugin))
>
> But I am sure I put My_Plugin.java and My_Plugin.class under plugins
> fold.

I answered a similar question recently:

http://article.gmane.org/gmane.comp.java.imagej/6992

The problem is that unless you package the class files, you _must not_
put
the class into a package. In other words, if you remove the line

        package plugins;

from your java file, it will start to work.

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: ImageJ Plugin

dscho
Hi,

On Tue, 6 Feb 2007, Hao An wrote:

> I do not have the line of "package plugins".

That is strange. Your mail said:

        java.lang.NoClassDefFoundError: My_Plugin(wrong
        name:plugins/My_Plugin

This suggests that somehow this plugin is compiled as if it were in the
package "plugins". With current ImageJ, it is not sufficient to put the
resulting class file in the directory "plugins". You _have_ to build a jar
if your class is in some package.

Maybe your compile script does strange things?

> I wrote the macro(write(call("java.lang.System.getProperty",
> "java.home")), and I got this
>
> C:\Program Files\java\jdk1.5.0_04\jre
>
> That looks fine to me.

Not to me. The final "jre" says that it is a Java Runtime Environment
(JRE), as opposed to Java Development Kit (JDK).

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: ImageJ Plugin

Hao An
In reply to this post by Hao An
So what do you get from your ImageJ, when you run macro
write(call("java.lang.System.getProperty",
"java.home"));

My installed imageJ1.37v (not ant-compiled one) show me:
C:\Program Files\ImageJ\jre

It is all jre. Why this one can have not problem for compile and run
plugins.

Thanks.

Hao



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Johannes Schindelin
Sent: Tuesday, February 06, 2007 5:27 PM
To: [hidden email]
Subject: Re: ImageJ Plugin

Hi,

On Tue, 6 Feb 2007, Hao An wrote:

> I do not have the line of "package plugins".

That is strange. Your mail said:

        java.lang.NoClassDefFoundError: My_Plugin(wrong
        name:plugins/My_Plugin

This suggests that somehow this plugin is compiled as if it were in the
package "plugins". With current ImageJ, it is not sufficient to put the
resulting class file in the directory "plugins". You _have_ to build a
jar
if your class is in some package.

Maybe your compile script does strange things?

> I wrote the macro(write(call("java.lang.System.getProperty",
> "java.home")), and I got this
>
> C:\Program Files\java\jdk1.5.0_04\jre
>
> That looks fine to me.

Not to me. The final "jre" says that it is a Java Runtime Environment
(JRE), as opposed to Java Development Kit (JDK).

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: ImageJ Plugin

Wayne Rasband
> So what do you get from your ImageJ, when you run macro
> write(call("java.lang.System.getProperty",
> "java.home"));
>
> My installed imageJ1.37v (not ant-compiled one) show me:
> C:\Program Files\ImageJ\jre
>
> It is all jre. Why this one can have not problem for compile
> and run plugins.

The "Compile and Run" command works because there is a copy of  
tools.jar in the Java extensions folder (ImageJ\jre\lib\ext), and  
tools.jar contains the javac compiler.

wayne

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Johannes Schindelin
> Sent: Tuesday, February 06, 2007 5:27 PM
> To: [hidden email]
> Subject: Re: ImageJ Plugin
>
> Hi,
>
> On Tue, 6 Feb 2007, Hao An wrote:
>
>> I do not have the line of "package plugins".
>
> That is strange. Your mail said:
>
> java.lang.NoClassDefFoundError: My_Plugin(wrong
> name:plugins/My_Plugin
>
> This suggests that somehow this plugin is compiled as if it were in  
> the
> package "plugins". With current ImageJ, it is not sufficient to put  
> the
> resulting class file in the directory "plugins". You _have_ to build a
> jar
> if your class is in some package.
>
> Maybe your compile script does strange things?
>
>> I wrote the macro(write(call("java.lang.System.getProperty",
>> "java.home")), and I got this
>>
>> C:\Program Files\java\jdk1.5.0_04\jre
>>
>> That looks fine to me.
>
> Not to me. The final "jre" says that it is a Java Runtime Environment
> (JRE), as opposed to Java Development Kit (JDK).
>
> Hth,
> Dscho
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: ImageJ Plugin

Dimiter Prodanov
In reply to this post by Hao An
Hi, there is a naming convention.
you name your plugin Plugin_ (with underscore).
Otherwise they do not appear in the menu.
The other thing that comes in mind is the definition of the
classpath.
Try someting like java  -cp .;ij.jar -jar ij.jar ... etc

best



_______________________________________________________________________
Dr Dimiter Prodanov, MD, Ph.D.

Neural Engineering Rehabilitation Laboratory
(Laboratoire de Génie de la Réhabilitation Neurale)
Département de Physiologie et Pharmacologie
Université catholique de Louvain
Avenue Hippocrate, 54
POBox UCL-5446 / B-1200 Bruxelles -Belgique-
Phone: 00-322-764 5596
Fax: 00-322-764 9422

http://www.md.ucl.ac.be/gren
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Portable ImageJ

Jon Harman
In reply to this post by dscho
Hi,

I just got a cute little USB flash drive.  (OK, I'm a little behind the
times.)  I want to show off my ImageJ plugin to friends with a Mac. I
have a PC.  I have copied the ImageJ directory to the flash drive.  What
else do I need to do so I can run it on a MAC? Can I just add the
ImageJ.app directory that comes in the Mac distribution?  Anything else?

Jon
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: ImageJ Plugin

Hao An
In reply to this post by Hao An
Thanks, Wayne.

I copied and pasted tool.jar to C:\Program
Files\java\jdk1.5.0_04\jre\lib\ext, then compile and run function works.

Yesterday, I only added tools.jar to the build path in Eclipse. Somehow
that did not work. Also I noticed the IDE-generated .class files had no
functions. For those plugin java files, I need to compile and run from
ImageJ first. Otherwise, I got the java.lang.NoClassDefFoundError
message. So my Eclipse-generated .class files were wrong and very
misleading, which have to be overwritten by clicking ImageJ's Compile
and Run.

Hao

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Rasband Wayne
Sent: Tuesday, February 06, 2007 11:02 PM
To: [hidden email]
Subject: Re: ImageJ Plugin

> So what do you get from your ImageJ, when you run macro
> write(call("java.lang.System.getProperty",
> "java.home"));
>
> My installed imageJ1.37v (not ant-compiled one) show me:
> C:\Program Files\ImageJ\jre
>
> It is all jre. Why this one can have not problem for compile
> and run plugins.

The "Compile and Run" command works because there is a copy of  
tools.jar in the Java extensions folder (ImageJ\jre\lib\ext), and  
tools.jar contains the javac compiler.

wayne

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Johannes Schindelin
> Sent: Tuesday, February 06, 2007 5:27 PM
> To: [hidden email]
> Subject: Re: ImageJ Plugin
>
> Hi,
>
> On Tue, 6 Feb 2007, Hao An wrote:
>
>> I do not have the line of "package plugins".
>
> That is strange. Your mail said:
>
> java.lang.NoClassDefFoundError: My_Plugin(wrong
> name:plugins/My_Plugin
>
> This suggests that somehow this plugin is compiled as if it were in  
> the
> package "plugins". With current ImageJ, it is not sufficient to put  
> the
> resulting class file in the directory "plugins". You _have_ to build a
> jar
> if your class is in some package.
>
> Maybe your compile script does strange things?
>
>> I wrote the macro(write(call("java.lang.System.getProperty",
>> "java.home")), and I got this
>>
>> C:\Program Files\java\jdk1.5.0_04\jre
>>
>> That looks fine to me.
>
> Not to me. The final "jre" says that it is a Java Runtime Environment
> (JRE), as opposed to Java Development Kit (JDK).
>
> Hth,
> Dscho