Introduction to Eclipse

Wuzhi Xu & Jeff Offutt
March 2006
  1. Overview

    Eclipse is an open source integrated development environment (IDE) whose primary target language is Java. It includes a syntax-directed (smart) editor for Java and automatically compiles Java classes. It is also possible to integrate other tools into Eclipse.


  2. Installation
  3. Getting Started
    1. Click on "go to workbench" on the splash screen
    2. A blank screen with several windows and lots of buttons will appear. Start by creating a project and import a Java program.
    3. Creating a project: File → New → Project
      1. Choose Java Project (default), click Next
      2. Enter a name ("intro"), let the other choices default, click Next
      3. Let the Java Settings choices default, click Finish
    4. Get the "Navigator" view: Window → Show View → Navigator
    5. Create a source and bin directory: right click on "intro" in Navigator window → New → Source Folder
      1. Enter src into Folder name, click Finish
      2. Let the Java Settings choices default, click Finish
    6. Import, edit and run a Java class: Right click on src → Import...
      1. Choose File system, click Next
      2. Browse to the appropriate directory
      3. Click by the Java file (or files) to import into Eclipse, click Finish
      4. Any compile errors or warnings will appear in the Problems window
      5. Open src in the Navigator window, double click on the Java file name
      6. The Java class should appear in the center editor window
      7. Click on the down arrow by the green right arrow, choose Run from the pulldown
      8. Right click Java Application
      9. Use the Arguments tab to enter arguments
      10. Click Run to run the program. Outputs will appear in the console window.

  4. Java Programming in Eclipse

    The tutorial for the following tasks is referenced in the Help Contents → Java development user guide in Eclipse.

    1. Create a Java project. Getting Started → Basic tutorial → Creating your first Java project
    2. Compile a Java program. There is no need to compile a Java program manually. Eclipse automatically compiles your Java program and marks syntax errors with red underlines
    3. Run a Java program. Getting Started → Basic tutorial → Running your programs
    4. Create a new Java class. Getting Started → Basic tutorial → Creating a new Java class
    5. Move Java elements (refactor) Getting Started → Basic tutorial → Moving and copying Java elements
    6. Rename Java elements (refactor) Getting Started → Basic tutorial → Renaming and copying Java elements
    Some useful functions in the Java editor:
    1. Eclipse automatically creates matching parentheses, curly braces, and square braces.
    2. Use content assistant. Getting Started → Basic tutorial → Editing Java elements → Using content assistant
    3. Use quick fix. Concepts → Quick fix
    4. Add comments. Tasks → Using the Java editor → Commenting and uncommenting lines of code
    5. Shift code left/right. Tasks → Using the Java editor → Shifting lines of code left and right
    6. Using surround with try/catch. Tasks → Using the Java editor → Using surround with try/catch
    7. Generating getter and setter methods. Tasks → Using the Java editor → Generating getters and setters

  5. Some Useful Plugins
    Three useful plugins are discussed here. There are two ways to install plugins.
    1. Use the update manager. This way is easier and safer. In the Help Content of eclipse, see Workbench User Guide → Tasks → Updating feature with the update manager
    2. Put the new plugins into the a plugin directory under the Eclipse home (such as eclipse_home/plugins/). Then restart eclipse.

    1. Oxygen plugin for XML

      This plugin provides an editor for XML, XML schema, DTD, XSL, XML and CSS.

    2. Tomcat plugin for web development

      This plugin helps configure the web server tomcat.

      • The zip file can be downloaded from http://www.sysdeo.com/eclipse/tomcatplugin. This webpage has instructions for installation. It needs to be installed manually.
      • Restart Eclipse after installing.
      • Configure tomcat in Eclipse. In the Eclipse menu, go to Window → Preference. In the left side of window, select tomcat and the configuration form for tomcat should appear. Select the version of your installed tomcat, enter the tomcat home directory, and enter the tomcat configuration file, which is usually "TOMCAT_HOME"/conf/server.xml.
      • Create an Eclipse project for tomcat. In the Eclipse menu, New → project → tomcat project. Give a name for project and choose next. Enter a directory name in the "subdirectory to set as the web application root". Tomcat will load whatever is in this directory, so it is better to use a separate directory, not a root directory.
      • Eclipse automatically configures context setting in Tomcat.
      • You can use the tomcat menu in the Eclipse menu to start, stop, and restart tomcat.
    3. WebTool plugin for web development

      This is an editor for HTML and JSP. The update site is http://download.eclipse.org/webtools/updates/. It will download other plugins that WebTool needs.