The argument as to which is the best IDE for Java development can reach religious fervor, and most software engineers have their own particular favorite. This chapter features Eclipse because it meets the criteria of being open source and offers most of the features necessary for a productive development platform.
It is also very popular with the Java development community and one of the slickest-looking Java development tools arounda factor which, in combination with its free status, may account for its huge popularity.
What Is Eclipse?
Eclipse is not strictly an IDE but is instead a generic Java-based platform for hosting development tools. The Eclipse Platform uses pluggable tools to build IDEs for supporting the development of a range of applications using a diverse set of technologies. The base Eclipse platform provides the functionality to detect, load, and integrate different development tools known as plug-ins into an Eclipse workbench. Collectively, these plug-ins form an IDE for a specific development technology, for example, Java, Smalltalk, or C++.
Eclipse's pedigree can be traced back to IBM. In producing tools for the IBM range of development products, the project teams at IBM found themselves continually producing IDEs from scratch for each new product. Recognizing this approach as wasteful in both time and effort, IBM focused its attention on developing a generic IDE platform that could be tailored for each new product. The Eclipse Platform was the result of this effort. IBM then contributed the source for the platform to the open source community and established and funded the Eclipse Foundation to encourage the development of the platform.
In its basic state, Eclipse is too generic for developing applications. To make Eclipse usable, the download comes complete with Java Development Tooling (JDT), a collection of tools targeted at the development of Java applications. The JDT provides the Eclipse Platform with all the features necessary for developing, running, testing, and debugging Java applications. In this chapter, we look at additional plug-in tools for supporting the development of J2EE solutions.
Installing and Running Eclipse
The Eclipse Web site is located at http://www.eclipse.org. This site provides the news on the Eclipse platform, articles, documentation, and the latest versions of Eclipse ready for download. The full Eclipse download comes complete with the JDT, so Eclipse is all ready to go for Java development.
Because Eclipse is a Java application, you must have a suitable JVM installed. Eclipse works with multiple versions, but check the site for details.
For the installation, you may either pick up the designated formal release or take a build from the current development stream. Certain development builds are periodically flagged as being stable, so if you want to see all the latest features, then go for one of these. However, if you're new to Eclipse, you may wish to download a reliable formal release.
Eclipse is downloaded as an archive and extracted into an appropriate local directory. On a Microsoft Windows platform, launch Eclipse using the eclipse.exe executable.
Although Eclipse runs directly from this file, it is advisable to set a few configuration parameters before starting the IDE. Specifically, you can tell Eclipse the JVM to use with the -vm flag. Explicitly stating the JVM is useful for machines with multiple JVM versions installed and avoids problems when upgrading to new versions of the J2SE platform.
Here is an example of the command line for running Eclipse with this option set:
eclipse.exe -vm c:\jre\bin\javaw.exe
You can set the option on the Windows platform by creating a desktop shortcut and providing the additional command-line arguments.
You can specify several parameters on the command line for optimizing the JVM to squeeze out extra performance from Eclipse. You may find the following settings result in Eclipse starting up considerably quicker on your system: - vmargs -Xverify:none -XX:+UseParallelGC -XX:PermSize=20M -XX:MaxNew-Size=32M -XX:NewSize=32M -Xmx256m -Xms256m.
Note that the setting of all these parameters is optional and serves purely to enable the customization of the Eclipse platform for your specific environment. Eclipse runs perfectly well straight out of the box.
The Eclipse Workspace
Eclipse adopts the concept of a user's workspace for managing applications under development. A workspace comprises a series of projects, and each project maps directly to a directory on the file system. Under a project directory resides all the source files for building a specific application or component.
Within a workspace, dependencies can be expressed between projects that govern build order. This makes workspaces an effective mechanism for organizing applications and allows large systems to be broken down into smaller subprojects.
The build constraints imposed by an IDE may prevent the implementation of your desired project structure. It is necessary to ascertain how an IDE organizes its directory structure and determine if the structure will scale to enable large project teams to work effectively.
From version 3.0, Eclipse supports the use of multiple workspaces and allows you to create a new workspace or select an existing one at startup. Alternatively, the location of the workspace can be passed to Eclipse on the command line with the data argument. For example, eclipse data c:\myproject\workspace.
The Eclipse Workbench Paradigm
Developers interact with Eclipse using the workbench paradigm, which is based on the concept of editors, views, and perspectives:
An example of an editor and a view is the Java source editor and the accompanying outline view. Here the outline view displays the structure of the Java class open in the editor.
Perspectives are a common source of confusion when learning the intricacies of Eclipse, since they are a concept not normally found in IDEs. Essentially, perspectives are a convenience for organizing editors and views according to a logical grouping, such as Java development or debugging.
Figure 13-1 shows the Eclipse workbench with a Java file open for editing. In addition to the editor, three views are visible in the perspective: the package explorer, which shows the Java project's package structure; the outline view, which provides an at-a-glance overview of the methods and attributes of the class being edited; and the console, responsible for displaying all output.
Figure 13-1. The Eclipse workbench.
Perspectives can take a little time to become familiar with, but after some experimentation, you'll find them a useful way of organizing the workbench.
Extending the Workbench with Plug-in Tools
The ability to tailor an IDE for a particular environment with custom plug-in tools is an important feature. The Eclipse Platform takes the use of plug-ins to the extreme and relies on plug-ins to provide the workbench with the development features required for a particular language or technology.
Plug-in tools are both the Eclipse Platform's main strength and its Achilles' heel. Heavy reliance on modular development tools makes the platform infinitely extendable and customizable. On the downside, the use of multiple tools can lead to integration problems, with badly behaving plug-ins causing instability within the workbench. Such instability, if it occurs, is extremely frustrating, especially as reliability must rank as one of the top requirements for an IDE.
When selecting a plug-in, you should determine the version of Eclipse the new tool supports. Tool versions that target a formal Eclipse release are likely to be more stable than those targeting a milestone, and hence a beta, version of Eclipseuser beware!
Numerous plug-in tools are available for the Eclipse Platform, with a highly active Eclipse community engaged in the development of both open source and commercial tools. The teams involved in tool development are required to "commune" away from the main Eclipse site. Sadly, this can make tracking down appropriate plug-ins difficult.
Two sites that carry an extensive list of tools are http://www.eclipse-plugins.info and http://www.eclipseplugincentral.com. Each of these resources provides searching facilities and sorts plug-in tools by category. The sites also rank each tool according to activity and download rate, making it easy to see which tools developers are actively using.
This chapter introduces a number of tools for enhancing Eclipse for performing J2EE development tasks. Table 13-1 gives a selection of popular open source and commercial tools available for the workbench.
The next section looks at the features of an IDE necessary for supporting J2EE projects.