DEV Community

Committed Software
Committed Software

Posted on • Originally published at committed.software on

Setting up Eclipse

bryan goff 356687

Setting up an IDE is always going to be a personal thing, but here’s what we think is a starting standard for Java development in Eclipse.

All the configuration options are under Window -> Preferences.

Formatting (under Java -> Code style -> Formatter)

Firstly and most importantly, we use the Google coding style. While we might not 100% agree with every rule; it’s a widely known, generally good and comprehensive start point which has formatters available for Eclipse.

To install the formatter:

Whilst the spaces vs tabs is an eternal debate, we standardise on spaces and thankfully it keeps CheckStyle quiet.

Maven (under Maven)

When debugging in Eclipse its nice to have the source code and javadoc of external libraries at your fingertips. Since we use Maven as our build system:

  • Window -> Preferences -> Maven and check Download Artifact Sources and Download Artifact JavaDoc.

We have a Maven proxy on our network, which reduces duplicate downloads for multiple people and workspaces, but if you are bandwidth limited then this option might not be for you.

Clean up (under Java -> Code Style -> Clean up)

Clean up is used to mass-tidy your code. Eclipse has one built in but we have something stricter. Basically this allows you mirror your Save Actions (see below), but you can import and export it in Eclipse.

Our clean up configuration is basically everything on, except “Sort members” and “Add unimplemented methods”. (We’ll put a link to the exported file some day!)

Save actions (under Java -> Editor > Save actions)

Why this is different to Clean up we don’t know, but that’s Eclipse. Sadly you can’t import here, and really this is more important that clean up (since it runs automatically on save).

You should enable everything! That is:

  • Format source code (format all lines)
  • Organize imports
  • Additional actions

Under Additional actions, we mirror our Clean up actions except where it gets in the way of development. For example, we don’t remove unused local variables or unused private members since that often means they get deleted mid-development (i.e. if you press save before you’ve finished coding a method). The same is true for final variables.

So we use Save Actions to get a reasonable clean output during development, then perform clean up prior to committing.

Type filters (Java -> Appearance -> Type Filters)

It’s really annoying when Eclipse offers you java.awt.List as the primary autocomplete option, but you can fix that.

Add the following packages to improve your sanity:

  • java.awt.* (hide the out of date!)
  • java.util.logging.* and org.apache.log4j.* (hiding the logging frameworks we’re not using, we use Slf4j)
  • com.sun.* (you probably shouldn’t be playing with this)
  • groovy.* and scala.* (since we don’t use much Groovy or Scala we don’t want to see their types)

Credit: Photo by Bryan Goff on Unsplash

Latest comments (1)

Collapse
 
romaincarrillo profile image
RomainCarrillo

Nice checklist for a good workspace setting 👍
I would add the Autocompletion triggers as they are not activated by default on new workspaces, witch is quitte annoying.