Setting up Eclipse to create and debug plugins for ImageJ

最近在做一个关于卫星遥感全链路仿真的项目,由于项目是基于ImageJ开发,而ImageJ提供了强大的插件机制,所以特来写一个东西说明如何将自己的代码转化为ImageJ的插件。

  • 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 is 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 is 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 that the output folder is set TestPlugin_/bin

  • On the Project tab, click Add… and select your previously created IJ project containing the ImageJ source.
  • Click Finish

  • Create your Java plugin files. In our 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" />

<property name="build" location="bin" />

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

<property name="pluginsDir" location="$basedir/../../IJ/plugins/" />

<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 in the Source lookup path, Add→Add Java Project. Select the TestPlugin_ project. This step is crucial if you want to step into your plugin source during the debug phase. Apply the changes.

  • If you select Debug, ImageJ will start and your TESTPlugin_ will show up in the Plugins menu…
  • Set breakpoints in plugins or in the ImageJ source, the debugger should break accordingly.

后注:当然上文只是其中一种方法,也还有其他方法可以实现!!!

如何在Eclipse中开发并调试自己的插件(或者说如何将自己的代码插件化)的更多相关文章

  1. 老李分享:Eclipse中开发性能测试loadrunner脚本

    老李分享:Eclipse中开发性能测试loadrunner脚本 前篇我分享了如何用loadrunner搭建javauser的性能测试脚本环境,本次我来告诉大家如何在eclipse开发loadrunne ...

  2. 如何在Eclipse中写Processing的sketch

    有时候人们需要写更复杂的sketch,此时Processing提供的IDE就略显单薄,下面将介绍如何在eclipse中开发Processing. 一共分4步: 一.搭建环境:安装JRE.JDK.Ecl ...

  3. 在Eclipse中开发C/C++项目

    摘要:通过本文你将获得如何在Eclipse平台上开发C/C++项目的总体认识.虽然Eclipse主要被用来开发Java项目,但它的框架使得它很容易实现对其他开发语言的支持.在这篇文章里,你将学会如何使 ...

  4. 【Eclipse】如何在Eclipse中使用命令行?

    如何在Eclipse中使用命令行? 虽然我们已经有了像 Eclipse 这样高级的 IDE,但是我们有时候也是需要在开发的时候使用 Windows 的命令行,来运行一些独立的程序.在两个程序中切换来切 ...

  5. 如何在Eclipse中设置默认的JSP文件头部编码

    如何在Eclipse中设置默认的JSP文件头部编码 一般,我们为了以后在导入和导出程序的时候(特别是项目较大,文件多)一般都默认文件编码格式为UTF-8 如果你通常都是通过Eclipse来编写程序,那 ...

  6. 如何在Eclipse中添加Tomcat的jar包

    原文:如何在Eclipse中添加Tomcat的jar包 右键项目工程,点击Java Build Path 点击Add Library,选择Server Runtime 选择Tomcat版本 此时就看到 ...

  7. 如何在eclipse中安装Jess

    如何在eclipse中安装Jess 浏览:49 | 更新:2014-05-12 16:39 这个文章帮了不少忙,感谢! 但经我实践,还要把插件那些文件向/dropins/sdk下也放一份,才能成功. ...

  8. 如何在Eclipse中配置Tomcat(免安装版)

    如何在Eclipse中配置Tomcat(免安装版) 2013-10-09 23:19wgelgrsh | 分类:JAVA相关 | 浏览642次 分享到:   2013-10-10 17:10提问者采纳 ...

  9. 如何在Eclipse中添加Servlet-api.jar的方法

    方法一: 点击窗口->首选项->java->构建路径->类路径变量->新建:将你的tomcat目录下的common/lib/servlet.jar加进来.如果你建立了一个 ...

随机推荐

  1. _itemFailedToPlayToEnd: { kind = 1; new = 2; old = 0; }

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvenVveW91MTMxNA==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...

  2. Trie树-脏词过滤应用

    Trie树,又称字符查找树.前缀树,主要用于字符匹配(详见http://en.wikipedia.org/wiki/Trie).适合做关键词查找,比如查找文章中的关键字然后给他们加链接. 当然对脏词的 ...

  3. Js模板引擎mustache

    mustache.js是一个简单强大的Javascript模板引擎,使用它可以简化在js代码中的html编写,压缩后只有9KB,非常值得在项目中使用.本文总结它的使用方法和一些使用心得,内容不算很高深 ...

  4. 有用的jQuery布局插件推荐

    网页设计中排版也是很重要的,但有些比较难的网页排版我们可以用一些jQuery来实现,今天文章中主要分享一些有用的jQuery布局插件,有类似Pinterest流布局插件.友荐的滑动提示块以及其它jQu ...

  5. R-plot

    颜色.图例和线 在散点图中添加信息.图例以及回归线. 模拟数据 #模拟数据 dat <- data.frame(X = runif(100,-2,2),T1 = gl(n=4,k=25,labe ...

  6. UVA 1343 The Rotation Game

    题意: 给出图,往A-H方向旋转,使中间8个格子数字相同.要求旋转次数最少,操作序列字典序尽量小. 分析: 用一维数组存24个方格.二维数组代表每个方向对应的7个方格.IDA*剪枝是当8-8个方格中重 ...

  7. jsonsql

    http://www.trentrichardson.com/jsonsql/ 可以对json数组用sql语法进行操作,主要是查询取指定字段.条件.指定字段排序及获取多少条数据,返回值json. js ...

  8. 【11.2noip冲刺赛】 循环整数 (分段打表)

    [问题描述]moreD在学习完循环小数之后发现循环是个很美好的性质.自己只需要记住短短的循环节以及循环次数(次数大于1,且是整数)就可以记住整个数字了.因为背诵数字变得方便了,moreD决定背诵[L, ...

  9. C++ vector 实现二维数组时, 在类的头文件中定义时遇到"应输入类型符"的问题?

    见下,当我在类的声明文件中定义二维vector时,提示我应输入类型说明符; 但是相同的格式定义,在类中将二维vector修改为在源文件中定义就可以顺利通过,并顺利执行打印 打印结果如下: 望大神来解惑 ...

  10. js常用DOM操作

    在博客园看到了苏夏写的常用DOM整理文章,地址:http://www.cnblogs.com/cabbagen/p/4579412.html,然后抽时间都试了一下这些常用的DOM操作.在这里记录一下. ...