0% found this document useful (0 votes)
193 views4 pages

Debugging Imagej Plugins in Netbeans

This document provides instructions for setting up ImageJ plugins for debugging in NetBeans IDE. The summary is: 1. Download and install NetBeans IDE and the ImageJ source code. Create a new Java project in NetBeans and select the ImageJ source folder. 2. Configure the project build path to include the ImageJ source and ij.jar files. Modify build files to compile and run plugins from the NetBeans IDE. 3. Write a new plugin Java class, compile it, and debug it by running ImageJ in the IDE. Breakpoints can be set and the plugin debugged within NetBeans.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
193 views4 pages

Debugging Imagej Plugins in Netbeans

This document provides instructions for setting up ImageJ plugins for debugging in NetBeans IDE. The summary is: 1. Download and install NetBeans IDE and the ImageJ source code. Create a new Java project in NetBeans and select the ImageJ source folder. 2. Configure the project build path to include the ImageJ source and ij.jar files. Modify build files to compile and run plugins from the NetBeans IDE. 3. Write a new plugin Java class, compile it, and debug it by running ImageJ in the IDE. Breakpoints can be set and the plugin debugged within NetBeans.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 4

Debugging ImageJ Plugins in NetBeans

1. Downloading NetBeans and the ImageJ Source file


1.
Download the installer:
NetBeans IDE 8.0.2 works better and faster with JDK distribution, so you can
download the Oracles co-bundled package from the links below. You may check
your OS type 32-bit (x86) or 64 bit (x64) via System Settings -> Details.

Download the x86 or x64 package:


http://www.oracle.com/technetwork/articles/javase/jdk-netbeans-jsp-142931.html
You can also download the other bundles at https://netbeans.org/downloads/

1.a. If you are working in Linux, give executable permission.


Press Ctrl+Alt+T on your keyboard to open the terminal. When it opens, run the
command below to make the installer executable.
chmod +x ~/Downloads/jdk-8-nb-8-linux-*.sh

You may change the file name jdk-8-nb-8-linux-*.sh in the code to yours, also
do this in next command.
1.b. Start the installer.
In the terminal run:
cd ~/Downloads && ./jdk-8-nb-8-linux-*.sh

This will bring up the install wizard. Just follow it and youll finally get the
NetBeans IDE 8 installed on your system.
(Optional) To uninstall the IDE, run ./uninstall.sh in the install directory.
2.

Download the latest ImageJ source code from;

http://rsb.info.nih.gov/ij/download/src/
3.
Unzip the ImageJ source. The folder "source" in the directory where you
unzip this file is the ImageJ source folder. Note: If you are working in Windows,
copy to directory directly in C, or in any other folder where you have full
permissions from the operational system.

4: In order to make easier the installation, you can create a new plugin code
directly from imageJ. Then:
1. Copy the source code to the ImageJ folder and unzip it.
2. Replace the plugins folder by your own plugins folder (old plugins sources).
Setting Up ImageJ in NetBeans
1. Run NetBeans
2. Go to the File>New Project... dialog
3.

In the Choose Project window:

4.

Select Choose Project >Java>Java Free-Form Project"


Click "Next >"
In the Name and Location window:

5.
6.

Click "Browse..." next to the location text box.


Select and choose the source folder where the ImageJ build.xml file is
located. At this point, NetBeans will fill in the four text boxes with the
appropriate entries.
Click "Next >"
Build and Run Actions
Click "Next >"
Source Package Folders
Click "Add Folder..."
Select and choose the folder "...source\ij"
Click "Add Folder..."
Select and choose the folder "...source\plugins"
Remove the . folder

In Source Level choose the Java JDK 1.X (we are going to use 1.8 this
semester) you are going to use.
Click "Finish"

Building ImageJ with NetBeans


1.
Double click the build.xml file and delete the " target= "1.X"" at the
end of line 9,

replace source= "1.X" by the last version of Java: source= "1.8"


and delete the lines related to the files that appeared in the plugins folder that
comes with source, that is:
line 22 : "<copy file="plugins/MacAdapter.class"
tofile="build/MacAdapter.class" />"
line 23: "<copy file="plugins/JavaScriptEvaluator.class"
tofile="build/JavaScriptEvaluator.class" /> "
2.
Go to the Run>Build Main Project or Build Project(ImageJ) (Ignore the red
error messages in the ImageJ build output.) If you received the message Build
Failed, read the errors and delete the characters that produces the errors and
compile again.
3.
Go to the File> Project Properties (ImageJ)
4.
Select the Java Sources Classpath category
5.
Select ij[ij] in the as the Source Package Folder
6.
Click "Add JAR/Folder..."
7.
Select and choose the ij.jar file which NetBeans just built in the source
directory
8.
Change the Source Package Folder to plugins[plugins]
9.
Click "Add JAR/Folder..."
10.
Select and choose the ij.jar file again
11.
Verify that the Java Platform is the JDK platform from SUN.
12.
11.
Click "OK"
Compiling and Debugging Plugins
1.
Right click on the plugins folder and go to New>Java Class... or
select one of your own plugins and go to step 5.
2.
Type in the name of your plugin
3.
Click "Finish"
4.
Write or paste your plugin into the Java Editor window.
5.
Select Run>Compile File. This step can also be done by the following
instructions: Right click on the name of the plugin that you want to compile and
use command Compile File.
6.
Click "Generate"
7.
In the ide-file-targets.xml file that was just created, change in line 9
<javac destdir="${build.classes.dir}" includes="${files}"
source="1.7" srcdir="plugins">
change "${build.classes.dir}" to "plugins
and source="1.5" to the version of Java you will use: source="1.8"
8.
Delete line 8 in the ide-file-targets.xml file:
<mkdir dir="${build.classes.dir}"/>
9. Change line 12 in the build.xml file from <exclude name="plugins/*" /> to
<!--exclude name="plugins/*" /-->

Note: That is this line becomes a comment by using <!--->


10.
Select your plugin from the ImageJ Project tree
11.
Go to Run>Compile "(The name of your plugin)" or Run>Compile File
12.
Go to Debug>Debug Main Project or Debug>Debug Project (ImageJ)
13.
Click "Set Output..."
14.
Click "OK"
15.
Go to Debug>Debug Main Project or Debug>Debug Project (ImageJ)
16.
Click "Generate"
17.
Go to Debug>Debug Main Project (ImageJ will run. The plugin you
created will be in the plugins menu).
Steps 18 to 20 can be avoided if everything goes well and the debug runs well
now, if no goes to step 18.
18.
Go to Window>Debugging>Sources.
19.
Although the ij and plugins sources could already be included in the
source root, include both sources again by right clicking in the Source Root
window-> Add Source Root.
20.
Check all the folders in the Sources tab .
21.
Run you plugin from the ImageJ plugins menu. NetBeans will debug your
plugin and stop at any specified breakpoints.
NOTA: If the code does not work, then change line 36 in file build.xml, for <copy
file="ij.jar" toDir="C:\source" />

You might also like