Tutorials‎ > ‎

Java Eclipse EE installation guide

Tested on: Eclipse JEE Luna SR2

Java Development Kit with Cryptography Extension (JCE) Unlimited Strength 

Download the latest Java SE Development Kit and the Java Cryptography Extension (JCE) Unlimited Strength here.
Install the JDK in "C:\Java\jdk_<version>". (When the installer wants to install the JRE, press the cancel button)
Next unzip the "local_policy.jar" and the "US_export_policy.jar" to the directory  "C:\Java\jdk_<version>\jre\lib\security". (overwrite existing jars)

Configure
Add JAVA_HOME to the environment variables with value "C:\Java\jdk_<version>".


Apache Ant
Download the latest Apache Ant version and unzip it in "C:\Java".

Configure
Add ANT_HOME to the environment variables with value "C:\Java\apache-ant_<version>".


Apache Maven
Download the latest Apache Maven version and unzip it in "C:\Java".

Configure
Add MAVEN_HOME to the environment variables with value "C:\Java\apache-maven_<version>".
Make the following additions to %MAVEN_HOME%\conf\settings.xml:
<settings> 
    <localRepository>${home_directory}\projects\localRepository</localRepository>
</settings>


Configure PATH environment variable

Add "%JAVA_HOME%\bin;%ANT_HOME%\bin;%MAVEN_HOME%\bin" at the beginning of the PATH environment variable. (without the " !)


Eclipse

Tip: Cleanup old Eclipse files on Microsoft Windows
Delete the directories "C:\Users\<username>\AppData\Local\Eclipse" and "C:\Users\<username>\.eclipse".

Install
Create a shortcut on your desktop from "C:\Java\eclipse\eclipse.exe".

Configure memory usage
In the "C:\Java\eclipse\eclipse.ini" file change:
-Xms40m
-Xmx512m
To:
-Xms2048m
-Xmx2048m

Update
In the menu, select "Help->Check for Updates".

Plugins via Eclipse Marketplace
All plugins that we use are open source.
Plug-ins are installed from Eclipse! In this section we assume that Eclipse started without errors.

To install a plugin, in the menu, select "Help" -> "Eclipse Marketplace...".
Select "Eclipse Marketplace" and click "next". Search by keyword and click the Install button to install the plugins you need.

Findbugs Eclipse Plugin
Keyword: findbugs eclipse
What to install: Everything

EclEmma Java Code Coverage
Keyword: eclemma
What to install: Everything

CheckStyle Plug-in (eclipse-cs)
Keyword: checkstyle plugin
What to install: Everything

FileSync
Keyword: filesync
What to install: Everything

Eclipse plugins, not via Eclipse Marketplace
To install a plugin, in the menu, select "Help" -> "Install New Software". Paste the url of the plugin in the field "Work with:" and press Enter. Wait until the message "Pending" disappears, select the parts you want to install and click "Next" twice. Accept the license agreement(s) and click "Finish".

Subclipse (if you need a subversion client)
URL: Lookup your svn version under the download tab at: http://subclipse.tigris.org/
What to install: Subclipse

PMD from Eclipse

Apache Directory Studio (LDAP browser)
What to install: Apache Directory Studio LDAP Browser, Apache Directory Studio LDIF Editor, Apache Directory Studio Schema Editor 

Open shell and folder from Eclipse
What to install: Everything

Eclipse ResourceBundle Editor Plugin
What to install: Everything

Configure Eclipse workspace
By default Eclipse will ask you for a workspace when it starts. Choose "${home_directory}\projects\workspace". If for some reason this has been disabled, you can re-enable it by selecting "Window->Preferences" in the menu, searching for "workspace" and checking "prompt for workspace on startup". You can also explicitly switch your workspace by selecting "File -> Switch workspace" in the menu.

Switch encoding to UTF-8
In the menu, select "Window->Preferences". Search for "Encoding", switch all encoding options to UTF-8 and click "Apply".

Switch file delimeter to UNIX style
In the menu, select "Window->Preferences->General->Workspace", set "New text file line delimeter" to "Unix" and click "Apply".

Set line length
In the menu, select "Window->Preferences". Search for "Width", fill in 140 everywhere and click "Apply".

Disable limit on Console output
In the menu, select "Window->Preferences", navigate to "Run/Debug->Console" and uncheck "Limit console output" and click "Apply".

Set code formatters
In the menu select "Window->Preferences", navigate to "Ant->Editor->Formatter" and for "Maximum line width (characters)" set the value 140.

In the menu select "Window->Preferences", navigate to "Java->Code Style->Formatter" and click on the "Edit" button.
  1. For "Profile name:" set the value "${youre_name}".
  2. Enable "Statements within 'switch' body".
  3. Go to the tab "Line Wrapping" and set "Maximum line width:" to the value "140".
  4. Go to the tab "Comments" and set "Maximum line width for comments:" to the value "140".
  5. Click on the "OK" button.

In the menu select "Window->Preferences", navigate to "Javascript->Code Style->Formatter" and click on the "Edit" button.
  1. For "Profile name:" set the value "${youre_name}".
  2. Enable "Statements within 'switch' body".
  3. Go to the tab "Line Wrapping" and set "Maximum line width:" to the value "140".
  4. Go to the tab "Comments" and set "Maximum line width for comments:" to the value "140".
  5. Click on the "OK" button.
Always set static import at the bottom (like intelij)
In the menu select "Window->Preferences", navigate to "Java->Code Style->Organize Imports" and click on the "New Static" button.
  1. For "Enter a prefix (e.g. 'org.eclipse') or '*' to import all imports:" set the value "*".
  2. Click on the "OK" button.
NOTE: Make sure the "*-all unmatched static imports" is set to the bottom!

Switch on all Java Warnings
In the menu, select "Window->Preferences" and navigate to "Java->Compiler->Errors/Warnings".
Change all "Ignore" to "Warning", except for:
  • "Unqualified access to instance field"
  • "Non-externalized strings(missing/unused $NON-NLS$ tag):"
  • "Method can be static"
  • "Method can potentially be static"

Make sure to leave the following options unchecked:
  • "Signal even if 'default' case exists"
  • "Include constructor or setter method parameters"
  • "Suppress optional errors with '@SuppressWarnings'"
  • "Enable annotion-based null analysis"

In the menu, select "Window->Preferences", navigate to "Java->Compiler->Javadoc" and change "Malformed Javadoc comments" to "Warning"; also check all sub-options.

In the menu, select "Window->Preferences", navigate to "Java->Findbugs":
  • Change "analysis effort" to "Maximal".
  • Enable all options for "Reported (visible) bugs categories", except for "Experimental".

Use Maven in Eclipse
In the menu, select "Window->Preferences" and navigate to "Maven".
Enable options:
  • "Download Artifact Sources".
  • "Download Artifact JavaDoc".

In the menu, select "Window->Preferences" and navigate to "Maven->Installations".
Click "Add" and select the %MAVEN_HOME% directory.
Select "External C:\Java\apache-maven-... " and click OK.

In the menu, select "Window->Preferences" and navigate to "Maven->User Settings".
For "Global Settings (..)", click "Browse" and select the "%MAVEN_HOME%/conf" directory.
Click "Reindex" and click "Apply".

Use Ant in Eclipse
In the menu, select "Window->Preferences" and navigate to "Ant->Runtime". Click "Ant Home" and select the %ANT_HOME% directory.

Text editor preferences
In the menu, select "Window->Preferences" and navigate to "General->Editors->Text Editors":
  1. Select " Show print margin" and fill the field "Print margin column" with 140
  2. Select "Show line numbers"
  3. Click the Apply button.

Save actions
"Save actions" are actions that are executed whenever a file is saved.
In the menu, select "Window->Preferences" and navigate to "Java->Editor->Save Actions":
  1. Enable all options and select "Format all lines".
  2. Click on the "Configure" button.
  3. On tab "Code Organizing":
    1. Enable "Remove trailing whitespaces" and select "All lines".
  4. On tab "Code Style":
    1. Enable "Use blocks in if/while/for/do statements" and select "Always".
    2. Enable "Convert for loops to enhanced".
    3. Enable "Use parentheses in expressions" and select "Only if necessary".
    4. Enable "Use modifier 'final' where possible" and only select "parameters".
    5. Enable "Convert functional interface instances"and select "Use lambda where possible".
  5. On tab "Member Accesses":
    1. Enable "Use 'this' qualifier for field access" and select "Only if necessary" .
    2. Enable "Use 'this' qualifier for method access" and select "Only if necessary" .
  6. On tab "Missing Code":
    1. Enable all options.
  7. On tab "Unnecessary Code":
    1. Enable "Remove unused imports".
    2. Enable "Remove unnecesary cast".
    3. Enable "Remove unnecesary '$NON-NLS$' tags".
NOTE: On tab "Code Organizing" do not check "Correct indentation", this will conflict with your code formatter!

In the menu, select "Window->Preferences" and navigate to "JavaScript->Editor->Save Actions":
  1. Enable all options.
  2. Click on the "Configure" button.
  3. On tab "Code Style":
    1. Enable "Use blocks in if/while/for/do statements" and select "Always".
    2. Enable  "Use parentheses in expressions" and select "Only if necessary".
  4. On tab "Unnecessary Code":
    1. Enable "Remove unnecesary '$NON-NLS$' tags".
  5. On tab "Code Organizing":
    1. Enable "Remove trailing whitespaces" and select "All lines".

Disable DTD warings in XML
In the menu, select "Window->Preferences" and navigate to "XML->XML Files->Validation":
  1. Select "Ignore" for "No grammar specified:". (This will remove the warning when a DTD file is missing)
  2. Click the Apply button.

Configure Eclipse projects
Various checks have to be enabled per project:
  1. Right-click the project and select "properties".
  2. Go to "Findbugs" and check both "Run automatically" and "(also on full build)".
  3. Click "OK".

Additional options for the "Java perspective"
To display the maven webapp folder in the project, perform the following steps:
  1. Right-click the project and select "properties".
  2. Go to "Java Build Path" and select the tab "Source".
  3. Click "Add folder ...", select "src\main\webapp" and click "OK".
  4. Double click the "Excluded:(None)" part of "<project name>/src/main/webapp".
  5. Click the "Add ..." button of the "Exclusion patterns:" part.
  6. Fill in "**" and click "OK".
  7. Select the tab "Order and Export".
  8. Select "<project name>/src/main/webapp" and click "Down" once.
  9. Click "OK".