This article shows you how to download and set up Eclipse in preparation for developing Java applications and includes configuring memory settings and if necessary alternate JDK versions. Eclipse is an Integrated Development Environment that provides a set of basic elements for a development environment. This environment is extended by different plug-ins that provide different features for different development tools, environments and frameworks. It is assumed the user is starting from scratch and will be downloading everything fresh. Once downloaded, we will install everything, and set up our environment.
64 Bit Windows
Some plug-ins do not support 64 bit JVMs on Windows, JBoss Developer Tools being one example. If you need to use these plug-ins, you will need to install a 32-bit JDK to use them, and we will configure Eclipse to use that JDK instead. This also means you will be unable to use a 64-bit version of Eclipse.
Installing and setting up Eclipse
We’ll start by downloading the Eclipse SDK which is the base IDE that we will be installing plug-ins into. At the time of writing, Eclipse SDK 3.5.2 is the most recent version. You need to download the version for Java EE developers since it contains most of the other required plug-ins for things like web development. You can download Eclipse from the Eclipse download site. Once downloaded, unzip it into a folder of your choice. The zip file usually creates a directory called
eclipse in the target directory that you unzipped the contents into.
By default, Eclipse uses lousy memory settings, but we can alter the
eclipse.ini file in the eclipse install directory to give us a better environment to work in. In the eclipse directory that appeared when you unzipped eclipse, there is an
eclipse.ini file. Edit this file and you will see a section that starts with
-vmargs. After this sections, you will see a couple of items starting with
-xmx. Edit this section so that it reads something like :
-Xms256m -Xmx512m -XX:MaxPermSize=256m
Don’t delete any other items in this section, just replace any that are existing and add others that are not already there.
The values you use depends on how much memory you have, but this is a decent amount. You can go with less, or more depending on how much free memory you have. See here for more details on Eclipse memory settings.
Running Eclipse under a different JVM
You can also tell Eclipse to run using a specific JVM or JDK in the
eclipse.ini file by adding a
-vm entry. You may need to do this if you have a 64-bit JVM and you need to run Eclipse under a 32-bit JVM. Another reason to add this to the configuration is because the Maven plug-ins we’ll be adding later prefers to run under a JDK instead of a JRE.
eclipse.ini and add the following 2 lines :
-vm C:\Program Files\Java\jdk1.6.xxx\bin\javaw.exe
Note : This must be on 2 separate lines and they must be placed before the
-vm arguments. Otherwise it will not work.
Now we have Eclipse installed and the environment configured, we’ll take it for a test. Run
eclipse.exe and Eclipse should launch. If not, check that you are using a valid path and filename for the
-vm option. If you are pointing to a 64-bit JVM and have 32-bit only plugins installed, this can cause silent failures.
When Eclipse starts up, if you go to Help->About Eclipse and the about dialog pops up. Click on the Installation Details button and in the window that pops up, click on the Configuration tab. In the big configuration listing, near the bottom of the window (you might have to scroll down a little) you should see something like :
eclipse.vm=C:\Program Files\Java\jdk1.6.xxxx\bin\javaw.exe eclipse.vmargs=-Dosgi.requiredJavaVersion=1.5 -Xms256m -Xmx512m -XX:MaxPermSize=256m
This confirms that our memory settings are being picked up, and the JDK we specified is being used.
Adding Maven Support
While this article doesn’t intend to cover any other plugins, Maven support in Eclipse is a rather fundamental one for getting started with projects. Here are the steps to install the m2Eclipse Maven plug-ins.
- Open the install manager by clicking the menu item Help->Install New Software….
- In the install manager, click the Add button to add a new update site.
- In the dialog that pops up, add m2Eclipse as the Name, and set Location to http://m2eclipse.sonatype.org/sites/m2e/. Click OK to close the dialog.
- Select the m2Eclipse URL in the drop down and click the check box next to the Maven Integration for Eclipse plug-in in the list and click Next.
- Once you agree to the licenses and click Finish Eclipse will download and install the plug-ins. Once complete, it will ask if you want to restart Eclipse now or later. It is best to re-start Eclipse before you start a new project or adding more plug-ins.