Difference between revisions of "Developing Fiji in Eclipse"

(screenshot thumbs larger)
m (space)
Line 130: Line 130:
;User Entries: <code>fiji/ij.jar</code> and all jars in <code>fiji/jars</code>, <code>fiji/plugins</code>, and<code>fiji/jars/jython2.2.1</code>
;User Entries: <code>fiji/ij.jar</code> and all jars in <code>fiji/jars</code>, <code>fiji/plugins</code>, and <code>fiji/jars/jython2.2.1</code>

Revision as of 12:38, 31 May 2009


This tutorial is about how to setup Eclipse for developing Fiji on a *nix operating system.

Install Eclipse

Install Eclipse using your preferred package manager or download the appropriate binaries of the Eclipse IDE for Java Developers. Launch Eclipse and decide for a workspace location (e.g. ~/worspace). For me, Eclipse is not stable with Sun Java 6. That is, you will eventually have to install Java 5 as an alternative JRE and make a custom launcher for Eclipse, e.g.

/usr/lib/jvm/java-1.5.0-sun/bin/java -cp /usr/lib/eclipse/startup.jar org.eclipse.core.launcher.Main

Install Git

Install Git using your preferred package manager or download from the Git website.

Checkout Fiji

Go into your Eclipse workspace and clone the Fiji repository

cd ~/workspace
git clone ssh://contrib@pacific.mpi-cbg.de/srv/git/fiji.git

This will create the folder ~/workspace/fiji where you have the core Fiji repository.

In order to run Fiji properly, it is suggested to use the JRE which is shipped with Fiji. This is a platform dependent submodule of the Fiji repository. Check it out with

cd ~/workspace/fiji
git submodule init java/linux-amd64
git submodule update java/linux-amd64

Check out all submodules that you want to work with e.g.

cd ~/workspace/fiji
git submodule init ImageJA
git submodule update ImageJA
git submodule init mpicbg
git submodule update mpicbg
git submodule init TrakEM2
git submodule update TrakEM2
git submodule init VIB
git submodule update VIB

Fiji comes with its own build system that we will later use from Eclipse. Test, if Fiji builds properly

cd ~/workspace/fiji
New Java Project

Create the Eclipse Project

Launch Eclipse and create a new Java project (New -> Java Project). As already mentioned, Fiji runs best with the included JRE that can be installed directly by the link Configure JREs. Add a new JRE located in the submodule path, e.g. ~/workspace/fiji/java/linux-amd64

Eclipse will add all found JRE system libraries automatically. Coose Fiji's JRE as the project specific JRE. `Next >' brings you to a screen for selecting sources and libraries. Eclipse automatically put into the source list everything it could find in the project folder. In Fiji's complex directory structure, this automatic selection is inadequate. Remove everything from the source list and put into it only what you want to edit, e.g.

  • ImageJA/ij
  • mpicbg
  • TrakEM2
  • VIB

If you want to develop a plugin without a separate submodule, put the respective folder under fiji/src-plugins into the source list.

Add all jars in fiji/jars and all jars in fiji/java/linux-amd64/jdk1.6.0_10/jre/lib/ext to the Libraries. You are safe not to forget any of the required dependencies when you also add all build targets (all jar files in fiji/plugins) whose sources you do not have in the source list. Unfortunately, the names of the submodules do not necessarily correlate with their build targets. Therefore, here come some examples:

source path build target
fiji/bio-formats fiji/plugins/loci_tools.jar
fiji/ImageJA/ij fiji/ij.jar
fiji/mpicbg fiji/plugins/mpicbg_.jar
fiji/TrakEM2 fiji/plugins/TrakEM2_.jar
fiji/VIB fiji/plugins/VIB_.jar

After finishing this, Eclipse once builds the Fiji project. There should not be any error message but several thousands of warnings that mostly come from Java1.4-style code or not required imports, variables or methods in the sources of authors who do not use an IDE as Eclipse and thus have no automatic assistance at cleaning up. All these warnings can be ignored having not effect to the functionality of the code.

Add Fiji Builder

Add Fiji Build

Eclipse compiles java sources to class files but Fiji requires those class files and corresponding configuration files in specific places. For this reason, the Fiji build system was developed and we will use it as an alternative builder for the Fiji project in Eclipse.

Select the Fiji project and open the project properties dialog (Project -> Properties). Under Builder, add a new Builder with the following properties:

Working Directory
New Run Configuration

Add a Run Configuration

Fiji can be launched conveniently from inside Eclipse. For this purpose, create a new Run Configuration (Run -> Run ...)

Main class
VM arguments
-Xms3000m -Xmx3000m -Dplugins.dir=${workspace_loc:fiji} -Dmacros.dir=${workspace_loc:fiji}
Working directory
Other: ${system_property:user.home}/Desktop/
Runtime JRE
Alternate JRE: Fiji Java
Java executable
Default (javaw)
User Entries
fiji/ij.jar and all jars in fiji/jars, fiji/plugins, and fiji/jars/jython2.2.1