Posted by
Peterbauer Thomas on
Dec 03, 2015; 9:56am
URL: http://imagej.273.s1.nabble.com/Eclipse-woes-tp5015004p5015114.html
On 2015-12-03 09:06, Dimiter Prodanov wrote:
> Hi Gabriel,
>
> I basically use the same strategy as Wilhelm.
> I typically code a main method so that I could start ImageJ from Eclipse by
> defining a launcher
>
> public static void main(String[] args) {
> try {
> File f=new File(args[0]);
> if (f.exists() && f.isDirectory() ) {
> System.setProperty("plugins.dir", args[0]);
> new ImageJ();
> } else {
> throw new IllegalArgumentException();
> }
> }
> catch (Exception ex) {
> IJ.log("plugins.dir misspecified\n");
> ex.printStackTrace();
> }
> }
Another very convenient way to launch ImageJ from within Eclipse for
simple projects without Maven is to define ImageJ either as an external
JAR or user library:
Project > Properties > Java Build Path > choose the Libraries tab > Add
External JARs...
and specify the path to ij.jar (you may use your normal ImageJ path).
You can even define ImageJ as User Library (Add Library...) and/or
attach source/javadocs to the external JAR/library.
Then, make a run configuration:
Project > Properties > Run/Debug Settings > New... (click Java Application)
In the "Main" tab of the dialog popping up, clicck "Search" to find the
main class of the ij.jar defined as external JAR/library. Eclipse will
find ij.ImageJ.
In the "Arguments" tab, pass the ImageJ "-run" command to launch your
plugin:
-run "NameOfMyPlugin"
You can give more arguments (-ijpath to specify the plugin directory,
-macro to run a macro to load a sample image before calling your plugin
etc.). Exceptions and System.out messages are redirected to the console
in Eclipse.
Best,
Thomas
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html