Help with Netbeans and plugins

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

Help with Netbeans and plugins

Todd V. Rovito
Hello fellow ImageJers,
I have been using ImageJ and writing plugins for ~ 8 months now. Things
have been going great! I currently use a bare development environment
with just the Sun JDK version on RedHat Enterprise Linux version 5.0.
Essentially I am using the Linux install of ImageJ version 1.37 and only
compiling my plugins. While this has worked for me I would like to
graduate to the Netbeans environment. Netbeans IDE would work better for
other people on the project.

Let me review my old development environment (don't laugh).
If I compile my plugins by hand using the following command (which I
placed in a makefile) everything works fine:

/opt/jdk1.5.0_14/bin/javac -cp
/usr/local/ImageJ/ij.jar:/opt/jdk1.5.0_14/lib/tools.jar,/home/rovitotv/AngelFireRoot/AngelFire/Utilities/ImageJPlugins
RAW_Side_By_Side_Reader_NightStare.java

I get a class file with no warnings or errors on the compile. I then
copy the class file to my ImageJ plugin directory and run ImageJ. The
plugin functions perfectly within ImageJ, I get the expected result!

Let me review the new Netbeans development setup. I followed the
directions posted here:
http://rsb.info.nih.gov/ij/developer/NBTutorial.html

I have installed Netbeans 6.0 since it is the latest with JDK 1.5.0_14.
So I follow the instructions and everything seems to work when I get
past the step "Building ImageJ with NetBeans" I have a ij.jar in the
~/NetBeansProject/ij138x folder. If I do a clean and build of the imageJ
project I get the following in the output:
clean:
clean:
Deleting directory /home/rovitotv/NetBeansProjects/ij138x/build
Deleting: /home/rovitotv/NetBeansProjects/ij138x/ij.jar
build:
compile:
Created dir: /home/rovitotv/NetBeansProjects/ij138x/build
Compiling 241 source files to /home/rovitotv/NetBeansProjects/ij138x/build
/home/rovitotv/NetBeansProjects/ij138x/ij/plugin/ScaleBar.java:81:
warning: unmappable character for encoding UTF8
units = "?m";
/home/rovitotv/NetBeansProjects/ij138x/ij/plugin/ScaleBar.java:161:
warning: unmappable character for encoding UTF8
units = "?m";
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 warnings
build:
Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
Copying 11 files to /home/rovitotv/NetBeansProjects/ij138x/build/macros
Building jar: /home/rovitotv/NetBeansProjects/ij138x/ij.jar
BUILD SUCCESSFUL (total time: 8 seconds)

Two warnings but at this point I am not too worried. Without adding any
plugins if I select "Run Main Project" ImageJ runs and the "About
ImageJ" dialog box shows ImageJ 1.38x with Java 1.5.0_14. ImageJ reads
files and allows me to make histograms. I can do the exact same thing
with the "Debug Main Project" option in Netbeans. At this point I am a
happy!

Now onto the plugins instructions are under "Compiling and Debugging
Plugins". I copy a plugin that builds and runs with my initial
development method as described above into
~/NetBeansProjects/ij138x/plugins. If I click on plugins and then
<default package> in the Netbeans project view the plugin java file
appears. I execute step 5 "Go to Build>Compile "(The name of your
plugin)" everything seems to compile fine. The output of "ImageJ
(compile-selected-files-in-plugins) looks like this:

compile-selected-files-in-plugins:
compile-selected-files-in-plugins:
BUILD SUCCESSFUL (total time: 0 seconds)

I then have a class file called
RAW_Side_By_Side_Reader_NightStare.class. Again if I take the class file
that Netbeans built and I place it into my running installation of
ImageJ in /usr/local/ImageJ/plugins/AngelFire sure enough it runs
perfectly!

Here is my problem when I get to step 16:
"Go to Run>Debug Main Project (ImageJ will run. The plugin you created
will be in the plugins menu)"

I get the following output in ImageJ(debug-nb):
debug-nb:
Duplicated project name in import. Project ImageJ defined first in
/home/rovitotv/NetBeansProjects/ij138x/nbproject/nbjdk.xml and again in
/home/rovitotv/NetBeansProjects/ij138x/build.xml
compile:
Compiling 1 source file to /home/rovitotv/NetBeansProjects/ij138x/build
/home/rovitotv/NetBeansProjects/ij138x/plugins/RAW_Side_By_Side_Reader_NightStare.java:82:
cannot find symbol
symbol : method format(java.lang.String,int,int)
location: class java.lang.String
filename = String.format("%1$06d-%2$06d.pos", 0, FrameNum);
/home/rovitotv/NetBeansProjects/ij138x/plugins/RAW_Side_By_Side_Reader_NightStare.java:125:
cannot find symbol
symbol : method format(java.lang.String,int,int)
location: class java.lang.String
filename = String.format("%1$06d-%2$06d.raw", 0, FrameNum);
/home/rovitotv/NetBeansProjects/ij138x/plugins/RAW_Side_By_Side_Reader_NightStare.java:135:
cannot find symbol
symbol : method format(java.lang.String,int,int)
location: class java.lang.String
filename = String.format("%1$06d-%2$06d.raw", CamNum, FrameNum);
3 errors
/home/rovitotv/NetBeansProjects/ij138x/nbproject/nbjdk.xml:23: The
following error occurred while executing this line:
/home/rovitotv/NetBeansProjects/ij138x/build.xml:9: Compile failed; see
the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

At this point I am stuck! I don't understand why this code does not
build when it builds perfectly calling javac by hand. This must be a
problem with my Netbeans configuration. Can anybody help? Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Help with Netbeans and plugins

Sami Badawi-2
Hi Todd,

I have created an open-source project called ShapeLogic (www.shapelogic.org)
 and the technique I am using there might apply to your problem.

I am using Maven 2 as my build environment. It is very simple to learn and
use. It works with both Eclipse, Netbeans and IntelliJ.

To build and deploy I have a 2 step process. Steps:
1: From command line run: mvn package  
This will run all unit tests and if there are no errors, build the jar file.

2: Move the newly build jar file shapelogic_-0.9.jar from shapelogic/target
to to ImageJ/plugin dir.

Note it has to have an underscore in the name to be picked up by ImageJ.

Debugging:
Just start the debugger from Eclipse, with these setting:
Debugging class: ij.ImageJ (main ImageJ class)
Start directory:  ImageJ directory:
VM setting: -Xmx50m

This should also work in Netbeans.

I started putting a description of my process up here:
http://www.shapelogic.org/setup.html
It should be done later today.

I hope this is helpful.

-Sami Badawi
Reply | Threaded
Open this post in threaded view
|

Re: Help with Netbeans and plugins

Todd V. Rovito
In reply to this post by Todd V. Rovito
Ok I got it to work.  It appears NetBeans is more picky about things
than just javac. After looking at String.format closer it actually
expects objects not primitive types.  Thanks for the responses.


Todd V. Rovito wrote:

> Hello fellow ImageJers,
> I have been using ImageJ and writing plugins for ~ 8 months now.
> Things have been going great! I currently use a bare development
> environment with just the Sun JDK version on RedHat Enterprise Linux
> version 5.0. Essentially I am using the Linux install of ImageJ
> version 1.37 and only compiling my plugins. While this has worked for
> me I would like to graduate to the Netbeans environment. Netbeans IDE
> would work better for other people on the project.
>
> Let me review my old development environment (don't laugh).
> If I compile my plugins by hand using the following command (which I
> placed in a makefile) everything works fine:
>
> /opt/jdk1.5.0_14/bin/javac -cp
> /usr/local/ImageJ/ij.jar:/opt/jdk1.5.0_14/lib/tools.jar,/home/rovitotv/AngelFireRoot/AngelFire/Utilities/ImageJPlugins
> RAW_Side_By_Side_Reader_NightStare.java
>
> I get a class file with no warnings or errors on the compile. I then
> copy the class file to my ImageJ plugin directory and run ImageJ. The
> plugin functions perfectly within ImageJ, I get the expected result!
>
> Let me review the new Netbeans development setup. I followed the
> directions posted here:
> http://rsb.info.nih.gov/ij/developer/NBTutorial.html
>
> I have installed Netbeans 6.0 since it is the latest with JDK
> 1.5.0_14. So I follow the instructions and everything seems to work
> when I get past the step "Building ImageJ with NetBeans" I have a
> ij.jar in the ~/NetBeansProject/ij138x folder. If I do a clean and
> build of the imageJ project I get the following in the output:
> clean:
> clean:
> Deleting directory /home/rovitotv/NetBeansProjects/ij138x/build
> Deleting: /home/rovitotv/NetBeansProjects/ij138x/ij.jar
> build:
> compile:
> Created dir: /home/rovitotv/NetBeansProjects/ij138x/build
> Compiling 241 source files to
> /home/rovitotv/NetBeansProjects/ij138x/build
> /home/rovitotv/NetBeansProjects/ij138x/ij/plugin/ScaleBar.java:81:
> warning: unmappable character for encoding UTF8
> units = "?m";
> /home/rovitotv/NetBeansProjects/ij138x/ij/plugin/ScaleBar.java:161:
> warning: unmappable character for encoding UTF8
> units = "?m";
> Note: Some input files use or override a deprecated API.
> Note: Recompile with -Xlint:deprecation for details.
> 2 warnings
> build:
> Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
> Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
> Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
> Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
> Copying 11 files to /home/rovitotv/NetBeansProjects/ij138x/build/macros
> Building jar: /home/rovitotv/NetBeansProjects/ij138x/ij.jar
> BUILD SUCCESSFUL (total time: 8 seconds)
>
> Two warnings but at this point I am not too worried. Without adding
> any plugins if I select "Run Main Project" ImageJ runs and the "About
> ImageJ" dialog box shows ImageJ 1.38x with Java 1.5.0_14. ImageJ reads
> files and allows me to make histograms. I can do the exact same thing
> with the "Debug Main Project" option in Netbeans. At this point I am a
> happy!
>
> Now onto the plugins instructions are under "Compiling and Debugging
> Plugins". I copy a plugin that builds and runs with my initial
> development method as described above into
> ~/NetBeansProjects/ij138x/plugins. If I click on plugins and then
> <default package> in the Netbeans project view the plugin java file
> appears. I execute step 5 "Go to Build>Compile "(The name of your
> plugin)" everything seems to compile fine. The output of "ImageJ
> (compile-selected-files-in-plugins) looks like this:
>
> compile-selected-files-in-plugins:
> compile-selected-files-in-plugins:
> BUILD SUCCESSFUL (total time: 0 seconds)
>
> I then have a class file called
> RAW_Side_By_Side_Reader_NightStare.class. Again if I take the class
> file that Netbeans built and I place it into my running installation
> of ImageJ in /usr/local/ImageJ/plugins/AngelFire sure enough it runs
> perfectly!
>
> Here is my problem when I get to step 16:
> "Go to Run>Debug Main Project (ImageJ will run. The plugin you created
> will be in the plugins menu)"
>
> I get the following output in ImageJ(debug-nb):
> debug-nb:
> Duplicated project name in import. Project ImageJ defined first in
> /home/rovitotv/NetBeansProjects/ij138x/nbproject/nbjdk.xml and again
> in /home/rovitotv/NetBeansProjects/ij138x/build.xml
> compile:
> Compiling 1 source file to /home/rovitotv/NetBeansProjects/ij138x/build
> /home/rovitotv/NetBeansProjects/ij138x/plugins/RAW_Side_By_Side_Reader_NightStare.java:82:
> cannot find symbol
> symbol : method format(java.lang.String,int,int)
> location: class java.lang.String
> filename = String.format("%1$06d-%2$06d.pos", 0, FrameNum);
> /home/rovitotv/NetBeansProjects/ij138x/plugins/RAW_Side_By_Side_Reader_NightStare.java:125:
> cannot find symbol
> symbol : method format(java.lang.String,int,int)
> location: class java.lang.String
> filename = String.format("%1$06d-%2$06d.raw", 0, FrameNum);
> /home/rovitotv/NetBeansProjects/ij138x/plugins/RAW_Side_By_Side_Reader_NightStare.java:135:
> cannot find symbol
> symbol : method format(java.lang.String,int,int)
> location: class java.lang.String
> filename = String.format("%1$06d-%2$06d.raw", CamNum, FrameNum);
> 3 errors
> /home/rovitotv/NetBeansProjects/ij138x/nbproject/nbjdk.xml:23: The
> following error occurred while executing this line:
> /home/rovitotv/NetBeansProjects/ij138x/build.xml:9: Compile failed;
> see the compiler error output for details.
> BUILD FAILED (total time: 0 seconds)
>
> At this point I am stuck! I don't understand why this code does not
> build when it builds perfectly calling javac by hand. This must be a
> problem with my Netbeans configuration. Can anybody help? Thanks.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Help with Netbeans and plugins

Todd V. Rovito
In reply to this post by Todd V. Rovito
Yep you hit the nail on the head!  If I change the build.xml file to
source = "1.5" and target = "1.5" sure enough my old code works.  The
best part is under file->"ImageJ Properties" there is a dialog selection
box labeled "Source Level" which I have set to JDK 1.5.  Apparently this
is not the same option.  Since I only have to make minor changes to get
my plugins to work I will stick with source = "1.4 and target = "1.4".  
Thanks again for the help.

Rasband Wayne wrote:

> Netbeans also uses javac but I suspect it is using the -source 1.4
> argument, which disables auto-boxing/unboxing (automatic conversion
> between primitive types and argument. This argument is set in ImageJ's
> build.xml file, which NetBeans is probably using.
>
> -wayne
>
>
>
> On Dec 23, 2007, at 5:25 PM, "Todd V. Rovito" <[hidden email]>
> wrote:
>
>> Ok I got it to work.  It appears NetBeans is more picky about things
>> than just javac. After looking at String.format closer it actually
>> expects objects not primitive types.  Thanks for the responses.
>>
>>
>> Rasband Wayne wrote:
>>> Todd,
>>>
>>> There is another NetBeans/ImageJ tutorial at
>>>
>>>    
>>> http://www.mbl.edu/research/labs/adlc/CamAcqJ/NetBeansforIJDevelopment.html 
>>>
>>>
>>> that you might want to take a look at.
>>>
>>> -wayne
>>>
>>>
>>> On Dec 23, 2007, at 9:36 AM, Todd V. Rovito wrote:
>>>
>>>> Hello fellow ImageJers,
>>>> I have been using ImageJ and writing plugins for ~ 8 months now.
>>>> Things have been going great! I currently use a bare development
>>>> environment with just the Sun JDK version on RedHat Enterprise
>>>> Linux version 5.0. Essentially I am using the Linux install of
>>>> ImageJ version 1.37 and only compiling my plugins. While this has
>>>> worked for me I would like to graduate to the Netbeans environment.
>>>> Netbeans IDE would work better for other people on the project.
>>>>
>>>> Let me review my old development environment (don't laugh).
>>>> If I compile my plugins by hand using the following command (which
>>>> I placed in a makefile) everything works fine:
>>>>
>>>> /opt/jdk1.5.0_14/bin/javac -cp
>>>> /usr/local/ImageJ/ij.jar:/opt/jdk1.5.0_14/lib/tools.jar,/home/rovitotv/AngelFireRoot/AngelFire/Utilities/ImageJPlugins
>>>> RAW_Side_By_Side_Reader_NightStare.java
>>>>
>>>> I get a class file with no warnings or errors on the compile. I
>>>> then copy the class file to my ImageJ plugin directory and run
>>>> ImageJ. The plugin functions perfectly within ImageJ, I get the
>>>> expected result!
>>>>
>>>> Let me review the new Netbeans development setup. I followed the
>>>> directions posted here:
>>>> http://rsb.info.nih.gov/ij/developer/NBTutorial.html
>>>>
>>>> I have installed Netbeans 6.0 since it is the latest with JDK
>>>> 1.5.0_14. So I follow the instructions and everything seems to work
>>>> when I get past the step "Building ImageJ with NetBeans" I have a
>>>> ij.jar in the ~/NetBeansProject/ij138x folder. If I do a clean and
>>>> build of the imageJ project I get the following in the output:
>>>> clean:
>>>> clean:
>>>> Deleting directory /home/rovitotv/NetBeansProjects/ij138x/build
>>>> Deleting: /home/rovitotv/NetBeansProjects/ij138x/ij.jar
>>>> build:
>>>> compile:
>>>> Created dir: /home/rovitotv/NetBeansProjects/ij138x/build
>>>> Compiling 241 source files to
>>>> /home/rovitotv/NetBeansProjects/ij138x/build
>>>> /home/rovitotv/NetBeansProjects/ij138x/ij/plugin/ScaleBar.java:81:
>>>> warning: unmappable character for encoding UTF8
>>>> units = "?m";
>>>> /home/rovitotv/NetBeansProjects/ij138x/ij/plugin/ScaleBar.java:161:
>>>> warning: unmappable character for encoding UTF8
>>>> units = "?m";
>>>> Note: Some input files use or override a deprecated API.
>>>> Note: Recompile with -Xlint:deprecation for details.
>>>> 2 warnings
>>>> build:
>>>> Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
>>>> Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
>>>> Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
>>>> Copying 1 file to /home/rovitotv/NetBeansProjects/ij138x/build
>>>> Copying 11 files to
>>>> /home/rovitotv/NetBeansProjects/ij138x/build/macros
>>>> Building jar: /home/rovitotv/NetBeansProjects/ij138x/ij.jar
>>>> BUILD SUCCESSFUL (total time: 8 seconds)
>>>>
>>>> Two warnings but at this point I am not too worried. Without adding
>>>> any plugins if I select "Run Main Project" ImageJ runs and the
>>>> "About ImageJ" dialog box shows ImageJ 1.38x with Java 1.5.0_14.
>>>> ImageJ reads files and allows me to make histograms. I can do the
>>>> exact same thing with the "Debug Main Project" option in Netbeans.
>>>> At this point I am a happy!
>>>>
>>>> Now onto the plugins instructions are under "Compiling and
>>>> Debugging Plugins". I copy a plugin that builds and runs with my
>>>> initial development method as described above into
>>>> ~/NetBeansProjects/ij138x/plugins. If I click on plugins and then
>>>> <default package> in the Netbeans project view the plugin java file
>>>> appears. I execute step 5 "Go to Build>Compile "(The name of your
>>>> plugin)" everything seems to compile fine. The output of "ImageJ
>>>> (compile-selected-files-in-plugins) looks like this:
>>>>
>>>> compile-selected-files-in-plugins:
>>>> compile-selected-files-in-plugins:
>>>> BUILD SUCCESSFUL (total time: 0 seconds)
>>>>
>>>> I then have a class file called
>>>> RAW_Side_By_Side_Reader_NightStare.class. Again if I take the class
>>>> file that Netbeans built and I place it into my running
>>>> installation of ImageJ in /usr/local/ImageJ/plugins/AngelFire sure
>>>> enough it runs perfectly!
>>>>
>>>> Here is my problem when I get to step 16:
>>>> "Go to Run>Debug Main Project (ImageJ will run. The plugin you
>>>> created will be in the plugins menu)"
>>>>
>>>> I get the following output in ImageJ(debug-nb):
>>>> debug-nb:
>>>> Duplicated project name in import. Project ImageJ defined first in
>>>> /home/rovitotv/NetBeansProjects/ij138x/nbproject/nbjdk.xml and
>>>> again in /home/rovitotv/NetBeansProjects/ij138x/build.xml
>>>> compile:
>>>> Compiling 1 source file to
>>>> /home/rovitotv/NetBeansProjects/ij138x/build
>>>> /home/rovitotv/NetBeansProjects/ij138x/plugins/RAW_Side_By_Side_Reader_NightStare.java:82:
>>>> cannot find symbol
>>>> symbol : method format(java.lang.String,int,int)
>>>> location: class java.lang.String
>>>> filename = String.format("%1$06d-%2$06d.pos", 0, FrameNum);
>>>> /home/rovitotv/NetBeansProjects/ij138x/plugins/RAW_Side_By_Side_Reader_NightStare.java:125:
>>>> cannot find symbol
>>>> symbol : method format(java.lang.String,int,int)
>>>> location: class java.lang.String
>>>> filename = String.format("%1$06d-%2$06d.raw", 0, FrameNum);
>>>> /home/rovitotv/NetBeansProjects/ij138x/plugins/RAW_Side_By_Side_Reader_NightStare.java:135:
>>>> cannot find symbol
>>>> symbol : method format(java.lang.String,int,int)
>>>> location: class java.lang.String
>>>> filename = String.format("%1$06d-%2$06d.raw", CamNum, FrameNum);
>>>> 3 errors
>>>> /home/rovitotv/NetBeansProjects/ij138x/nbproject/nbjdk.xml:23: The
>>>> following error occurred while executing this line:
>>>> /home/rovitotv/NetBeansProjects/ij138x/build.xml:9: Compile failed;
>>>> see the compiler error output for details.
>>>> BUILD FAILED (total time: 0 seconds)
>>>>
>>>> At this point I am stuck! I don't understand why this code does not
>>>> build when it builds perfectly calling javac by hand. This must be
>>>> a problem with my Netbeans configuration. Can anybody help? Thanks.
>>>
>>>
>>
>
>