Using User Plugins in Eclipse

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using User Plugins in Eclipse

Becksfort, Jared
Hello,

I cannot figure out how to use a plugin in the plugins folder using the Java API.

For example, I am able to open nifti images using nifti_io from ImageJ, and I check the recorder and it tells me to do this basically:

ImagePlus inImg = IJ.openImage(inFilename); // inFilename ends in .nii, so it should be using Nifti_Reader

But this code fails with

Exception in thread "main" java.lang.NullPointerException
        at ij.Menus.getPlugInsPath(Menus.java:1161)
        at ij.plugin.ClassChecker.getPathsAndNames(ClassChecker.java:68)
        at ij.plugin.ClassChecker.deleteDuplicates(ClassChecker.java:19)
        at ij.plugin.ClassChecker.run(ClassChecker.java:14)
        at ij.IJ.runPlugInUnchecked(IJ.java:175)
        at ij.IJ.runPlugIn(IJ.java:157)
        at ij.IJ.runPlugIn(IJ.java:143)
        at ij.IJ.runUserPlugIn(IJ.java:184)
        at ij.IJ.runPlugIn(IJ.java:154)
        at ij.IJ.runPlugIn(IJ.java:143)
        at ij.io.Opener.openWithHandleExtraFileTypes(Opener.java:412)
        at ij.io.Opener.openImage(Opener.java:289)
        at ij.io.Opener.openImage(Opener.java:308)
        at ij.IJ.openImage(IJ.java:1409)
        at utility.PreProcessor.main(PreProcessor.java:31)

I have tried a number of different things to resolve this, such as setting VM arguments -Dplugins.dir and -Dmacros.dir to the directory above plugins as mentioned in the docs.  I am using the Eclipse IDE.  I am trying to use nifti_io (or any other jar in the plugins directory) in Java code and can't seem to get it to work.

Thanks so much to anyone who can help,
Jared

Email Disclaimer:  www.stjude.org/emaildisclaimer
Consultation Disclaimer:  www.stjude.org/consultationdisclaimer

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Using User Plugins in Eclipse

dscho
Hi Jared,

On Sun, 14 Apr 2013, Becksfort, Jared wrote:

> I cannot figure out how to use a plugin in the plugins folder using the
> Java API.

Due to the architecture, this is a non-trivial problem. If you are trying
to debug a plugin without third-party dependencies, you can use the trick
described here:

        http://fiji.sc/Debugging#Debugging_plugins_in_an_IDE_.28Netbeans.2C_IntelliJ.2C_Eclipse.2C_etc.29

For the record, Fiji's Debug class is designed to adjust settings so that
you can run ImageJ inside, say, Eclipse:

https://github.com/fiji/fiji/blob/master/src-plugins/fiji-lib/src/main/java/fiji/Debug.java

If you are uncomfortable with adding fiji-lib as a dependency to your
project, feel free to replicate everything from that class.

Ciao,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Using User Plugins in Eclipse

Becksfort, Jared
Johannes,

Thank you very much for the quick and helpful response.  I have not tried it yet but am more optimistic now that it will work.  If I have more trouble I will post another message.

Jared

-----Original Message-----
From: Johannes Schindelin [mailto:[hidden email]]
Sent: Sunday, April 14, 2013 4:29 PM
To: Becksfort, Jared
Cc: [hidden email]
Subject: Re: Using User Plugins in Eclipse

Hi Jared,

On Sun, 14 Apr 2013, Becksfort, Jared wrote:

> I cannot figure out how to use a plugin in the plugins folder using
> the Java API.

Due to the architecture, this is a non-trivial problem. If you are trying to debug a plugin without third-party dependencies, you can use the trick described here:

        http://fiji.sc/Debugging#Debugging_plugins_in_an_IDE_.28Netbeans.2C_IntelliJ.2C_Eclipse.2C_etc.29

For the record, Fiji's Debug class is designed to adjust settings so that you can run ImageJ inside, say, Eclipse:

https://github.com/fiji/fiji/blob/master/src-plugins/fiji-lib/src/main/java/fiji/Debug.java

If you are uncomfortable with adding fiji-lib as a dependency to your project, feel free to replicate everything from that class.

Ciao,
Johannes


Email Disclaimer:  www.stjude.org/emaildisclaimer
Consultation Disclaimer:  www.stjude.org/consultationdisclaimer

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html