ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

An Introduction to the Eclipse IDE

by Scott Storkel

If you closely follow open source or Java programming, you may have heard some of the buzz surrounding Eclipse. Eclipse is an extensible, open source IDE (integrated development environment). The project was originally launched in November 2001, when IBM donated $40 million worth of source code from Websphere Studio Workbench and formed the Eclipse Consortium to manage the continued development of the tool.

The stated goals of Eclipse are "to develop a robust, full-featured, commercial-quality industry platform for the development of highly integrated tools." To that end, the Eclipse Consortium has been focused on three major projects:

  1. The Eclipse Project is responsible for developing the Eclipse IDE workbench (the "platform" for hosting Eclipse tools), the Java Development Tools (JDT), and the Plug-In Development Environment (PDE) used to extend the platform.

  2. The Eclipse Tools Project is focused on creating best-of-breed tools for the Eclipse platform. Current subprojects include a Cobol IDE, a C/C++ IDE, and an EMF modeling tool.

  3. The Eclipse Technology Project focuses on technology research, incubation, and education using the Eclipse platform.

The Eclipse platform, when combined with the JDT, offers many of the features you'd expect from a commercial-quality IDE: a syntax-highlighting editor, incremental code compilation, a thread-aware source-level debugger, a class navigator, a file/project manager, and interfaces to standard source control systems, such as CVS and ClearCase.

Eclipse also includes a number of unique features such as code refactoring, automatic code updates/installs (via the Update Manager), a task list, support for unit testing with JUnit, and integration with the Jakarta Ant build tool.

Despite the large number of standard features, Eclipse is different from traditional IDEs in a number of fundamental ways. Perhaps the most interesting feature of Eclipse is that it is completely platform- and language-neutral. In addition to the eclectic mix of languages supported by the Eclipse Consortium (Java, C/C++, Cobol), there are also projects underway to add support for languages as diverse as Python, Eiffel, PHP, Ruby, and C# to Eclipse.

Related Reading

Java In a Nutshell
By David Flanagan

Platform-wise, the Eclipse Consortium provides prebuilt binaries for Windows, Linux, Solaris, HP-UX, AIX, QNX, and Mac OS X. Much of the interest in Eclipse centers around the plug-in architecure and rich APIs provided by the Plug-in Development Environment for extending Eclipse. Adding support for a new type of editor, view, or programming language is remarkably easy, given the well-designed APIs and rich building blocks that Eclipse provides.

With hundreds of plug-in development projects in progress, industry giants like IBM, HP, and Rational (just acquired by IBM) providing resources, and design heavy-weights like Erich Gamma helping to guide the process, the future indeed looks bright for Eclipse.


By now you're probably wondering where you can get a copy of Eclipse for your platform and what you have to do to install it. The first thing you need to do is make sure you have an appropriate Java runtime available. Though Eclipse can compile your code for either 1.3 or 1.4 VMs, current versions were designed to run on a 1.3 VM. If you're not sure where to find an appropriate Java VM for your platform, you can find more information at eclipse.org.

Once you have a Java VM, you're ready to get Eclipse. Visit the Eclipse downloads page and grab the latest release build for your platform. All builds are delivered as .zip files. Unzip the archive into an appropriate directory and then read through any files that may be present in the readme directory.

Believe it or not, your install is now complete. If you've installed your JVM properly and unpacked the Eclipse archive correctly, you should be ready to run Eclipse for the first time. All binary distributions provide a launch application in the primary eclipse directory. The name of the launcher changes from platform to platform: eclipse.exe on Windows, eclipse on Solaris, and so on. The first time the Eclipse application is run, it will complete a few remaining install tasks (i.e., creation of a workspace directory for storing project files) before the environment comes up.


Once you have Eclipse installed and running, it's time to begin using it. After you initially launch Eclipse, you should see a window which looks something like this:

Click for larger view
Initial Eclipse window layout (You can click on the screen shot to open a full-size view.)

As you can see, the Eclipse IDE has a fairly standard menu bar:

Eclipse menu bar

and toolbar:

Eclipse toolbar

There is also a tabbed editor, currently showing the Welcome page:

Eclipse tabbed editor

Sample App

The File Navigator, Code Outline, and Task List are present, but don't contain any data yet. In order to continue our exploration of Eclipse, we'll create a simple Swing-based calculator program.

  1. Select File->New->Project... to begin creating your first Java project. In the wizard that appears, select Java from the list of possible project types in the left-hand list and Java Project from the right-hand list, then click the Next button.

    First page of the New Project wizard
    First page of the New Project wizard

  2. For the project name, enter Calculator, then click the Next button again.

    Second page of the New Project wizard
    Second page of the New Project wizard

  3. The final step of the wizard allows us to specify where source code and class files should live, specify any subprojects which might be needed by the current project, and any provide any libraries that may be necessary for the build. Select the Use source folder contained in the project radio button, then click the Create New Folder... button. Enter src for the name of the new folder. Click Yes when Eclipse asks if you want to update the Build output folder to Calculator/bin.

    Third page of the New Project wizard
    Third page of the New Project wizard

  4. Click the Finish button to have Eclipse create the project.

Once your project has been created, you may notice that the layout of the Eclipse window doesn't look quite the same as it did before you created the project: the Outline view has been moved to the left side of the window, the Navigator has been replaced with a Package Explorer, and so on.

Click for larger view
Java perspective (You can click on the screen shot to open a full-size view.)

This new layout is called the Java Perspective. A perspective, in Eclipse parlance, is a saved layout containing any number of different editors and views. Eclipse ships with a number of default perspectives (Resource, Java, Debug, etc.) that can be customized, or you can create completely new perspectives. Perspectives are managed using items from the Window menu or the perspective toolbar which normally appears along the left-hand edge of the Eclipse window.

Perspective selection toolbar

The next step in creating our Java project is to create the directories that will contain our source code. Switch to the Resource perspective using Window->Open Perspective->Resource. In the Navigator view, expand the folder tree until you see the src node. Select this node, then choose the File->New->Folder menu item. In the dialog that appears, make sure that the src directory is selected, then enter com in the Folder Name field.

Creating large numbers of folders using the New Folder dialog can be a bit cumbersome. Luckily, Eclipse is just as happy to let you do the work using your favorite filesystem interface: command shell, Windows Explorer, etc. Use one of these methods to create folders named devious and calculator under the com folder. Once you've done this, select any of the folders in the Navigator view and select the File->Refresh menu item. Eclipse will examine the filesystem and update the project to match. At this point, your project should look something like this:

Click for larger view
Folder creation complete (You can click on the screen shot to open a full-size view.)

One final note on file creation: in the early stages of a project, you may find yourself frequently running code, creating a new file or folder, adding some more code, compiling, and testing the code again. It's important to remember that the menus Eclipse displays are specific to a given perspective. So, when you switch to the Resource perspective to create a new file or folder in the Navigator view, you'll find that the Run menu, for instance, changes dramatically from the Run menu in the Java perspective. One solution to this particular problem is to use the Window->Show View menu to show the Navigator view in the Java perspective. If you want to make this a permanent change, you can use the Window->Save Perspective As... menu item to save your changes as either a new perspective or to replace the existing Java perspective.

Pages: 1, 2

Next Pagearrow