### Debugging ImageJ Plugins in NetBeans

> Downloading NetBeans and the ImageJ Source file
> 1. Download and install JDK 5.0 bundled with NetBeans 4.1 at the Sun Downloads page. Macintosh users should download NetBeans 4.1 for OS X from netbeans.org.
> 2. Download the latest ImageJ source code from 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
> Setting Up ImageJ in NetBeans
> Run NetBeans
> Go to the File>New Project... dialog
> 1. Choose Project
>    - Select General and "Java Project with Existing Ant Script"
>    - Click "Next >"
> 2. Name and Location
>    - 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 >"
> 3. Build and Run Actions
>    - Click "Next >"
> 4. Source Package Folders
>    - Click "Add Folder..."
>    - Select and choose the folder "...source\ij"
>    - Click "Add Folder..."
>    - Select and choose the folder "...source\plugins"
>    - Click "Finish"
> Building ImageJ with NetBeans
> 1. Java 5.0 users, double click the build.xml file and delete the " target= "1.1"" at the end of line 9
> 2. Go to the Build>Build Main Project (Ignore the red error messages in the ImageJ build output.)
> 3. Go to the File> "ImageJ" Properties
> 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. Click "OK"
> Compiling and Debugging Plugins
> 1. Right click on the plugins folder and go to New>Java Class...
> 2. Type in the name of your plugin
> 3. Click "Finish"
> 4. Write or paste your plugin into the Java Editor window.
> 5. Go to Build>Compile "(The name of your plugin)"
> 6. Click "Generate"
> 7. In the ide-file-targets.xml file that was just created, change "${build.classes.dir}" to "plugins" in line 9
> 8. Delete line 8 in the ide-file-targets.xml file
> 9. Change line 12 in the build.xml file from <exclude name="plugins/*" /> to <!--exclude name="plugins/*" /-->
> 10. Select your plugin from the ImageJ Project tree
> 11. Go to Build>Compile "(The name of your plugin)"
> 12. Go to Run>Debug Main Project
> 13. Click "Set Output..."
> 14. Click "OK"
> 15. Go to Run>Debug Main Project
> 16. Click "Generate"
> 17. Go to Run>Debug Main Project (ImageJ will run. The plugin you created will be in the plugins menu)
> 18. Go to Window>Debugging>Sources
> 19. Check all the folders in the Sources tab
> 20. Run you plugin from the ImageJ plugins menu. NetBeans will debug your plugin and stop at any specified breakpoints
> For a list of NetBeans debugging commands go the NetBeans Debugger page.
> For a more basic tutorial go to NetBeans Debugging Applications page.

> More Tutorials

> 1. Grant Harris at the Marine Biological Laboratory has written another ImageJ/NetBeans tutorial.
> 2. Patrick Pirrotte has written a guide for Eclipse users.

> [Return to ImageJ page]