Login  Register

Re: How to use jar file in ImageJ plugin?

Posted by Wayne Rasband on Jan 20, 2006; 2:35am
URL: http://imagej.273.s1.nabble.com/How-to-use-jar-file-in-ImageJ-plugin-tp3703985p3703986.html

>   I want to pack some class files in a jar file, and use this jar  
> file in ImageJ plugin.

There is an example at "http://rsb.info.nih.gov/ij/plugins/jar- 
demo.html".

>   Step 1: put MyClassA.java and MyClassB.java in D:\mypackage  
> directory
>   Step 2: go into D:\ directory, and type "javac MyClassA.java" and  
> "javac MyClassB.java" in Dos command

You do not need to use javac. You can compile and test plugins within  
ImageJ using the Plugins>Compile and Run command.

>   Step 3: how to use jar command to pack MyClassA.class and  
> MyClassB.class into a jar file?

Instructions for using the jar command are included with the example.

> Do I need to supply a manifest file?

A manifest file is not required. A plugins.config file is required if  
the jar file contains more than one plugin or you want to install a  
plugin somewhere other than the Plugins menu (e.g., in the  
File>Import menu).

>   Step 4: where should I put this jar file in order to ImageJ can  
> find  and I can use this jar file when develop ImageJ plugin?

Jar files go in the plugins folder, or immediate sub-folder.

>   I also have another two questions:
>   1. Does ImageJ support that loading plugins from jar file?

Yes.

>   2. It can not use "package" keyword in ImageJ plugin, is it?

The main class cannot use a package statement but classes called by  
the main class can.

-wayne