Eclipse WTP (Web Tools Platform)

Description:
Eclipse is a popular Integrated Development Environment (IDE). Its default configuration allows convenient editing, debugging and executing Java programs. Eclipse also has many powerful plugins. One useful combination of Eclipse packaged together with some plugins is WTP - Web Tools Platform.
Download at:
http://www.eclipse.org/webtools/
Preconditions:
JDK 1.6 should be already installed

Eclipse

  • Download the latest release of WTP. At the time of writing this, the file is wtp-all-in-one-sdk-R-1.5.5-200708291442-win32.zip.
  • Unzip it e.g. under c:\tools
  • For your convenience create a shortcut to eclipse.exe and place it to the desktop. (E.g. press the right mouse button, drag the file eclipse.exe from a "Windows Explorer" window and select Create Shortcuts Here from the menu.
  • Double-click the eclipse icon on the desktop. An Eclipse application should open.
  • If it proposes the workspace location, select some value not too deep down the directory tree (e.g. d:\myworkspace), check the option "Use this as the default and do not ask again", and press [OK].
  • Close the Welcome screen by closing the "Welcome" tab. The Eclipse application is now ready for new projects.

Check the installation

Create an empty Java project and place a simple Hello.java program there. (If you have difficulty creating a project, read a tutorial - open Help -> Help Contents and read the topic Java Development User Guide -> Getting Started -> Basic tutorial).

Hello.java
==========
public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello");
    }
}
  • Troubleshooting: If you do not see "Package Explorer" tab on the left side, select from the menu Window->Open Perspective->Java (default) and Window->Show View->Package Explorer
  • Eclipse compiles your Java files automatically (i.e. the menu option Project->Build Automatically is checked by default). This means that a new compiled file c:\temp\HelloProject\bin\mypackage\Hello.class is created, and it will be recompiled every time when Hello.java source file is changed in the Eclipse editor.
  • Run the project by selecting from Eclipse menu: Run->Run As->Java Application - a "Hello" message should be displayed in the console window.

Configuring Eclipse to work with Maven

  • Create a Maven archetype project (as described in Maven installation); run "mvn eclipse:eclipse" and create an Eclipse project in the directory "your_jarfilename".
  • It probably contains no compilation errors, but the project name is still marked by a little red cross. If it is, perform the following steps:
    • Right-click the project name and pick "Properties". Select "Java Build Path" in the left side of the dialog, and open "Libraries". You probably will see the following classpath entry: M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar
    • The cause of the error is undefined variable M2_REPO, which is the root of the Maven's repository. To define it, click button "Add Variable", in the next dialog - "Configure Variables", and in the next - "New".
    • In the dialog "New Variable Entry" write in the following values and check that the junit/junit/3.8.1/junit-3.8.1.jar is located under the Path you select
    Name: M2_REPO
    Path: d:\Documents and Settings\student\.m2\repository
    
  • If you do the abovementioned steps and avoid configuring Eclipse by hand, there is a good chance that all the tools (Maven, Eclipse, Subversion) will work correctly. The previous substeps need to be done only once after installation of Eclipse. After that M2_REPO will always include files from the Maven repository.