Developing Fiji in Eclipse
short URLFrom Fiji
Contents |
Introduction
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@fiji.sc/srv/git/fiji.git
This will create the folder ~/workspace/fiji where you have the core Fiji repository.
Note: change "contrib" for your user name in fiji.sc if you have an account there.
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. It will be automatically checked out when compiling Fiji:
cd ~/workspace/fiji ./Build.sh
Check out all submodules that you want to work with e.g.
cd ~/workspace/fiji git submodule update --init modules/mpicbg git submodule update --init modules/TrakEM2
Check out the master branch of each of these submodules
cd ~/workspace/fiji cd modules/mpicbg git checkout master cd ../TrakEM2 git checkout master
Note: if you check out blindly the master branch of all the submodules you are interested in, the compilation might fail. If you are interested in a compiling state, you need to stay with the state after git submodule update.
Fiji comes with its own build system that we will later use from Eclipse. Test, if Fiji builds properly
cd ~/workspace/fiji ./Build.sh ./fiji
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
Note: Eclipse will try to set fiji/bin as output folder, which already contains files. We recommend to set it instead to something else, e.g. fiji/build
Eclipse will add all found JRE system libraries automatically. Choose 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
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/jars/ij.jar |
| fiji/mpicbg | fiji/plugins/mpicbg_.jar |
| fiji/TrakEM2 | fiji/plugins/TrakEM2_.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 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:
- Location
-
${workspace_loc:/fiji}/fiji - Working Directory
-
${workspace_loc:/fiji} - Arguments
-
--build
Note: If you want to build TrakEM2, you will have to explicitly build required plugins in prior, that is
- Arguments
-
--build plugins/bUnwarpJ_.jar plugins/level_sets.jar all
Add a Run Configuration
Fiji can be launched conveniently from inside Eclipse. For this purpose, create a new Run Configuration (Run -> Run Configurations...)
- Main
-
- Project
- fiji
- Main class
- fiji.Main
- Arguments
-
- VM arguments
- -Xms3000m -Xmx3000m -Dplugins.dir=${workspace_loc:fiji} -Dmacros.dir=${workspace_loc:fiji}
- Working directory
- Other: ${system_property:user.home}/Desktop/
- JRE
-
- Runtime JRE
- Alternate JRE: Fiji Java
- Java executable
- Default (javaw)
- Classpath
-
- User Entries
-
fiji/ij.jarand all jars infiji/jars,fiji/plugins, andfiji/jars/jython2.2.1



