A current and well maintained IDE makes life a lot easier when developing web applications. Our favorite is Eclipse, and a new version of it is released every year. Here’s a quick review of the setup for the latest version.
Eclipse is a popular Integrated Development Environment (IDE); a single software environment that provides services for editing, building, testing, debugging, and deploying your web projects. It’s free and open-source. It’s also highly modular, allowing developers and users to create additional functionality to meet specific needs. This modularity however makes for some challenging configuration problems, which we’ll discuss as we set up the suite.
We have already covered Eclipse basics in earlier posts. Refer to that article for more information on the suite. Here we’ll simply revisit the installation and configuration process, plus the addition of important modules.
Downloading and Installation
Eclipse IDE can be downloaded from the Eclipse website. The download section can be found at http://www.eclipse.org/downloads/. The first thing you’ll notice when you arrive is that there are several bundles or packages of the IDE, each containing a various modules for specific applications such as C/C++ development, mobile development, testing, etc. Since we’re doing web development, choose the one for Eclipse IDE for Java EE Developers, 64-bit Windows edition in our case.
Each June, the Eclipse community releases a new version of the tool suite and associated packages, each named after a planetary element. As of this writing, the current version is named Mars and was released in June 2015.
Finally, as of the Mars release, Eclipse provides an ‘installer’ app on their Download page. Installing it allows you to subsequently choose, download, and install any current package. Eclipse installation is exceedingly simple however, so I recommend not bothering with a separate utility and downloading your Eclipse packages directly from the website.
When downloaded manually, the Windows package comes as a single zip file that can simply be extracted in any location. I suggest storing all your Eclipse zips in C:\Eclipse\, and then extract your files to C:\Eclipse\eclipse-jee-mars-1-win32-x86_64, for example.
To launch Eclipse, simply run C:\Eclipse\eclipse-jee-mars-1-win32-x86_64\eclipse\eclipse.exe.
Restoring Your Configuration
Earlier I recommended that you save your Eclipse settings and other configuration options in a separate file, possibly to distribute to other developers, or simply re-apply should you upgrade Eclipse. If you have an Eclipse Preferences File (*.epf), now’s the time to load it into your new version of Eclipse. Simply go to File->Import->General->Preferences in Eclipse, and enter the name of your preferences file.
You can select which configuration settings you would like to import. If you have different Java Runtime Environments (JREs) installed, you may want to skip importing those settings and configure your JREs manually.
Importing Controlled Projects
If you’re following good Configuration Management (CM) practices, you will be regularly checking in your code changes to a Revision Control server like Subversion. We’ve covered the basics of revision control in previous posts, so all we need now is to retrieve the projects we’ve stored there.
Several plugins are available to do this from within the Eclipse eco-system; we prefer Subclipse. To install it, go to Help->Eclipse Marketplace… from within Eclipse, search for ‘subclipse’, and download the latest version. Accept all default settings.
To check out a project from your archive, click File->Import->SVN->Checkout Projects from SVN. If this is the first time you’ve tried this, you must create a repository location that is used for this and future imports. Ask your administrator for the path to your repository, roughly of the form:
You may also be prompted for your username and password for your account on the server. If you click the ‘Save Password’ box, your credentials will be stored in the %APPDATA%\Subversion folder. Subsequent imports will uses these credentials automatically.
Next, pick the project folder you want to import. For more information on how to check in changes are create new projects, see the previous post.
Running Unit Tests
If you’re good about including complete unit tests with your projects as described in a previous post, you can run them on imported projects manually. Simply click on the run icon
on the toolbar, and run as ‘JUnit Test’. Eclipse’s built-in JUnit runner will execute all your tests and list your results in a separate window. If you’re interested in the percentage of code coverage your tests have, run your tests with ‘EclEmma’ (available from the Eclipse Marketplace) to get those statistics.
Using Maven in Eclipse – Mars is identical to that of recent versions. Maven support is built into the JEE package; projects can be created by clicking File->New->Maven Project.
Yearly releases of the Eclipse IDE rarely make noticeable changes to the functionality of the packages these days. Because the interaction of these modules can often lead to problems, it is always prudent to use the most current version. We’ll revisit the subject again in June 2016 to see what surprises await us in Eclipse – Neon.