How to develop and debug your own plugins in eclipse (or how to plug in your own code)

Source: Internet
Author: User

Setting up Eclipse-to-Create and debug plugins for ImageJ

recently, a project on full-link simulation of satellite remote sensing is being made, as the project is based on ImageJ Development, while ImageJ provides a powerful plug-in mechanism, so special to write a thing that explains how to translate your own code into ImageJ plug-in.

    • alt-file–> New
    • Select The Java Project Wizard and click Next

    • Project Name:ij. Check Create separate folders for sources and class files. Click Next

    • On the following panel, select Source tab and check if Default output folder was set to Ij/bin

    • On the Libraries tab click on Add external JARs, browse to your Java SDK library folder, select tools.jar Click Ok and click on Finish to create the project.

(On my Computer the Java SDK Library folder was located at C:\Program Files\java\jdk1.6.0_02\lib)

    • Finally, get the latest copy of IJ here, extract the zip
    • Copy the IJ folder and its subfolders into the source folder
    • Copy the images, macros and plugins folder and only ij_props.txt to the IJ project root.
    • Click on F5 to tell Eclipse to refresh its package list

Create a new plugin (or import your previously developed plugins).

    • alt-file–> New
    • Select The Java Project Wizard and click Next

    • Give your plugin a name (don ' t forget to add an underscore if you want it to appear in the ImageJ menu!)

    • On the Source tab, check the-the output folder is set Testplugin_/bin

    • On the Project tab, click Add ... and select your previously created IJ Project containing the ImageJ SOURC E.
    • Click Finish

    • Create your Java plugin files. In we example, I created a sample Testplugin_.java with the following content:

Import ij. IJ;

Import ij.plugin.PlugIn;

Public Class Testplugin_ implements PlugIn {

public void run(String arg) {

Ij. error("Hello world!" );

}

}

    • Create a file called Build.xml in the project root folder. A sample Build.xml file follows, which you should adapt to your needs.

<project Name="Testplugin_" default= "" basedir="." >

<description>

Testplugin_ Build File

</description>

<property name="src" location ="src" />

& Lt;property name= "build" location= "bin" />

<property name="dist" location ="dist" />

<property name="Pluginsdir" location ="$basedir/... /.. /ij/plugins/" />

& Lt;property name= "User.Name" value= "Patrick Pirrotte" />

<target Name="main" depends= "compress" description="Main Target ">

<echo>

Building the. jar file.

</echo>

</target>

<target name="Compress" depends= " Description=" Generate the Distribution ">

<jar jarfile="Testplugin_.jar">

<fileset dir="." includes="Plugins.config" />

<fileset dir="${build}" includes="**/*.*" />

<manifest>

<attribute name="built-by" value="${user.name}"/>

</manifest>

</jar>

<copy file="Testplugin_.jar" todir="${pluginsdir}" />

</target>

</project>

    • In the package Explorer, right click on the Testplugin_ project, click on Properties, select Builders, click  New ... and select Ant Builder

    • In the Main Tab, click Browse Workspace and select the Build.xml from your Testplugin_ project.

    • In the Targets tab, click Set Targets for both after clean and Auto build Targets, and Select both main and compress.
    • Click Ok twice to keep your changes.

    • Goto run→debug Configurations and create a new Java application Debug Configuration. Fill in IJ in the field Project, and ij. ImageJ in the field Main class.

    • Select The Source tab, then the source lookup path, Add→add Java Project. Select the testplugin_ project. This step was crucial if you want to step into your plugin source during the debug phase. Apply the changes.

    • If you select Debug, ImageJ'll start and your testplugin_ 'll show up in the Plugins menu ...
    • Set breakpoints in plugins or of the ImageJ source, the debugger should break accordingly.

Note: Of course, the above is just one of the methods, there are other ways to achieve!!!

How to develop and debug your own plug-in in eclipse (or how to plug in your own code)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.