A guide on how to include ImageJ into Eclipse and develop plugins using this IDE.
Author: Patrick Pirrotte (patrick@image-archive.org)
There are many different methods to include ImageJ into Eclipse to develop plugins. Four of them are described in this document. The recommended way is described in Method 1), while Method 4) is faster to setup for a quick hack.
(on my computer the Java SDK library folder is located at C:\Program Files\Java\jdk1.6.0_02\lib)
Create a new plugin (or import your previously developed plugins).
import ij.IJ; import ij.plugin.PlugIn; public class TestPlugin_ implements PlugIn { public void run(String arg) { IJ.error("Hello world!"); } }
<project name="TESTPlugin_" default="" basedir="."> <description> TESTPlugin_ build file </description> <property name="src" location="src" /> <property name="build" location="bin" /> <property name="dist" location="dist" /> <property name="pluginsDir" location="$basedir/../../IJ/plugins/" /> <property name="user.name" value="Patrick Pirrotte" /> <target name="main" depends="compress" description="Main target"> <echo> Building the .jar file. </echo> </target> <target name="compress" depends="" description="generate the distribution"> <jar jarfile="TESTPlugin_.jar"> <fileset dir="." includes="plugins.config" /> <fileset dir="${build}" includes="**/*.*" /> <manifest> <attribute name="Built-By" value="${user.name}"/> </manifest> </jar> <copy file="TESTPlugin_.jar" toDir="${pluginsDir}" /> </target> </project>
Installing the source into Eclipse will allow you to quick-jump between ImageJ classes and your own plugins. It's really really useful to browse through the ImageJ API inside Eclipse.
You can program your plugins which will be compiled against the ImageJ source code. To export your plugin go to File→Export and select JAR, export the jar to your ImageJ plugins folder.
(an alternative way proposed by Andy Weller)
[TODO: SCREENSHOTS WILL FOLLOW]
[TODO: SCREENSHOTS WILL FOLLOW]
You could basically add the ij.jar file as a library to your plugin as seen above. From this point on you'll be able to develop ImageJ plugins. To enable ImageJ source code browsing you will have to attach the source code to the freshly imported ij.jar. (thanks to Aaron Ponti for this tip)
You should now be able to navigate through the ImageJ source code as if you had created a standalone project for ImageJ itself.
Any improvements or bugs? Send me your comments (patrick@image-archive.org)