Difference between revisions of "Developing ImageJ in Eclipse"

m (Fix case.)
m (Add Curtis' and Christian's shortcuts.)
Line 72: Line 72:
* {{Key|Ctrl}}+{{Key|O}}: show outline
* {{Key|Ctrl}}+{{Key|O}}: show outline
* {{Key|Ctrl}}+{{Key|Space}}: auto-complete
* {{Key|Ctrl}}+{{Key|Space}}: auto-complete
* {{Key|Ctrl}}+{{Key|T}}: shows all implementations of interface or class
* {{Key|Alt}}+{{Key|Up}} or {{Key|Alt}}+{{Key|Down}}: move lines up or down

Revision as of 12:39, 5 September 2015


 Win.png  Avoid permissions issues. We recommend installing Eclipse outside of the Program Files directory. E.g.: C:\Users\frood\Programs\eclipse, where C:\Users\frood is your user directory.

Configuring Eclipse. After installing Eclipse, you will need to configure it to know about your JDK.

Use Wordpad to edit the eclipse.ini file in your Eclipse installation (e.g., C:\Users\frood\Programs\eclipse). (Do not use Notepad, because it will not handle the Unix-style line breaks properly.) Carefully follow these instructions to specify the proper JDK. Then save the file and quit Wordpad.

Now update Eclipse's JRE to be JDK-aware:

  • Launch Eclipse
  • From the menu choose Window › Preferences
  • Select Java › Installed JREs
  • Click Search..., navigate to your JDK installation folder (e.g., C:\Program Files\Java\jdk1.8.0_11) and click OK
  • Check the box next to the JRE that appears and click OK

 Tux.png  Avoid permissions issues. We recommend installing to $HOME/eclipse.

Do not use a package manager. For several reasons, we do not recommend installing Eclipse from a package manager. You may not get a new enough version of Eclipse (we recommend 4.3+), you will not get the Java Developers version that includes the M2E plugins, and you will likely have trouble installing additional plugins due to the permissions issues with the system-wide installation.

This article explains how to install and configure Eclipse for use with ImageJ development. Directions correspond to Eclipse 4.4 Luna, and may need adjustment for other versions.

Install and configure Eclipse

Install the Java Development Kit

  • Download and install the Java Development Kit (JDK) from the Java web site.

Install Eclipse

  • Unpack the archive to a location of your choice.
  • See the right-hand sidebars for platform-specific notes.

Clone the source code

Import the source code

  1. Choose File › Import from the Eclipse menu
  2. Select "Existing Maven Projects" and click Next
  3. Browse to the folder where you cloned the project source code
  4. Click Finish

Launching ImageJ

If you cloned the imagej project, you can launch the program as follows:

  1. In the Package Explorer, expand the imagej project
  2. Navigate into src/main/java
  3. Navigate into net.imagej
  4. Right-click on Main.java
  5. Choose "Run As" and then "Java Application"

Other projects will have different main classes.

Keyboard Shortcuts

For Mac, replace ^ Ctrl with Cmd

  • Shift+^ Ctrl+T: find objects
  • ^ Ctrl+1: quick fix
  • F3: jump to class (to edit the code, see snapshot coupling)
  • ^ Ctrl+O: show outline
  • ^ Ctrl+Space: auto-complete
  • ^ Ctrl+T: shows all implementations of interface or class
  • Alt+ or Alt+: move lines up or down