This is an archive of the old MediaWiki-based ImageJ wiki. The current website can be found at imagej.net.

Developing ImageJ in IntelliJ IDEA

Development
Topics
Overview
Philosophy
Architecture
Source code
Project management
Coding style
Debugging
Tools
GitHub
Git
Maven
IDEs
Travis
AppVeyor
Dotfiles
Guides
Writing plugins
ImageJ Ops
Contributing to a plugin
Distributing your plugins
Development lifecycle
Building a POM
Developing with Eclipse
Hands-on debugging
Adding new ops
Adding new formats
Using native libraries
Tips for developers
Tips for C++ developers
ImageJ 1.x plugins
Versioning
Logging
Uber-JARs

This article explains how to install and configure IntelliJ IDEA for use with ImageJ development. Directions correspond to IntelliJ IDEA 11.1, and may need adjustment for other versions.

Install and configure IDEA

  • Install Java Development Kit. Download and install Java SE 8 from the Java web site. Or install it via a package manager, if possible.

Import the ImageJ source

  1. From the IDEA menu, choose Version Control › Checkout from Version Control › Git
  2. For the Git Repository URL, enter: git://github.com/imagej/imagej
  3. Specify a Parent Directory, click Clone, and wait
  4. When prompted, click Yes to create an IntelliJ IDEA project from the sources

On some platforms, the first time you perform this procedure, you may be prompted to select the project JDK:

  1. Click the plus sign and choose "JSDK"
  2. Navigate to the directory containing your JDK installation

Launch the program

  1. Choose Run › Edit Configurations from the menu
  2. Click the Plus icon and choose Application
  3. In the Name field, type "ImageJ"
  4. Type "net.imagej.Main" for the Main class
  5. For "Use classpath and JDK of module" select "imagej" from the list
  6. Click OK
  7. Choose Run › Run 'ImageJ' from the menu

The project automatically builds before launching, so it may take a little while the first time.

Troubleshooting

Renaming SciJava @Plugin annotated classes

When renaming a classname which was annotated with SciJava's @Plugin annotation, an error may occur during launch of the application looking like:

[ERROR] Exception during event handling:
	[Event] org.scijava.module.event.ModulesUpdatedEvent
	context = org.scijava.Context@1a05aced
	consumed = false
	items[0] = label='About ImageJ...', iconPath='/icons/commands/information.png', priority=0.0, enabled=true, pluginType=Command
	items[1] = label='Preferences', priority=0.0, enabled=true, pluginType=Command
	items[2] = label='Quit', iconPath='/icons/commands/door_in.png', priority=0.0, enabled=true, pluginType=Command
	[Subscriber] org.scijava.menu.DefaultMenuService [priority = 0.0]
	[Method] protected void org.scijava.menu.DefaultMenuService.onEvent(org.scijava.module.event.ModulesUpdatedEvent)
java.lang.IllegalStateException: Can't overwrite cause with org.scijava.InstantiableException: Class not found: 

the.plugin.you.just.Renamed

The error may be related to some caching mechanism in the IDE. The solution is to clear the caches, e.g. by running mvn clean from the maven panel.