Eclipse IDE

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.
Download at:
http://www.eclipse.org
Preconditions:
JDK 5.0 should be already installed

Eclipse

  • Unzip %CD%\eclipse\eclipse-SDK-3.2.1-win32.zip under c:\tools
  • Press and hold the right mouse button on the file c:\tools\eclipse\eclipse.exe within the Total Commander and select Create Shortcut. Drag the shortcut to eclipse.exe to the desktop.
  • 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. c:\myworkspace), check the option "Use this as the default and do not ask again", and press [OK]. For some projects you may need to prepare the directory layout manually or by Maven, so you should remember, where the workspace is located.
  • Close the Welcome screen by closing the "Welcome" tab. The Eclipse application is now ready for new projects.

Check the installation

  • Create the following directory structure (e.g. under c:\temp):
+HelloProject
  +src
    +mypackage
      Hello.java
  +bin
  • Here the directory names are preceded by "+", and the absolute path to Hello.java file is c:\myworkspace\HelloProject\src\mypackage\Hello.java. The source of the Hello.java can be like this (the class should be in "mypackage"):
Hello.java
==========
package mypackage;

public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello");
    }
}
  • Select in the Eclipse menu File->New->Project. Pick "Java Project", press "Next".
  • Select "Create project from existing source" and press [Browse]. Select directory c:\temp\HelloProject.
  • Copy-paste the project's name "HelloProject" also to the "Project Name field" (see picture)
A fragment of "New Java Project" dialog box
  • Press [Finish]. There should be a new project created in Eclipse (see picture):
A simple project in Eclipse
  • 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
  • Troubleshooting: If "mypackage" is not displayed # with the squarelike package icon, right-click "HelloProject" in the Package Explorer, select "Properties", select "Java Build Path" in the dialog and open the "Source" tab. Make sure that "HelloProject/src" is the only source folder and "HelloProject/bin" is the default output folder.
  • 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.

Installing Eclipse Plugins

  • Unzip %CD%\eclipse\tk.eclipse.plugin.htmleditor_2.0.0.zip and %CD%\eclipse\xmlbuddy_2[1].0.72.zip so that two new directories are created under c:\tools\eclipse\plugins - namely com.objfac.xmleditor_2.0.72 and tk.eclipse.plugin.htmleditor_2.0.0

Check the installation:

  • You will see the effects of these plugins, if you edit XML or HTML files within Eclipse - it will be pretty colored source text with some help of DTD grammars, when editing XML files.
  • If you get annoying error messages (red underlines or blue question marks in your XML files, it could be a misbehaving XML Buddy. Open that XML file and select from the Eclipse menu XML->Clear Validate and the messages will go away.

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.