What is Eclipse?
Eclipse is an integrated development environment (IDE). Although Eclipse has grown to be all things to all programmers, we will concentrate on its application as a Java development environment.
Overview
After explaining how to download and unpack and start up Eclipse, we'll explain how to create a LingPipe project directly from it's ant file (with a little help on the classpath). With a project in hand, we can use Eclipse to browse and edit code; the reverse indexing of code for browsing makes it easy to get a feel for a package.
The real strength of Eclipse emerges in its refactoring capabilities.
It automatically finds problems and better yet, can automatically fix
the simple ones. Eclipse is also useful for stepwise debugging. A good
way to get to know someone else's code is to step through it from the
main() down to where something interesting happens.
Eclipse Version 3.2
This demo is based on Version 3.2 of Eclipse for 32-bit Windows. There also reference implementations for x86 Linuxes of various flavors, Mac OS X, SPARC Solaris, and some other Unixes. As of this writing, Red Hat Linux and Windows XP 32-bit are the only versions that support the 1.5 JDK.
Downloading and Unpacking
Eclipse does not need to be installed; just download and unpack it. To download, go to the following URL:
Select the
Download now: Eclipse SDK
Other
downloads link and select the download for the platform you're
using.
Once you've downloaded, just decompress the zip file and place it somewhere convenient, which we'll call
$ECLIPSE.
The root of the distribution contrains an executable that is run to startup Eclipse.
Running
In Windows, the executable is at the top of the distribution. You can double click it or run it as a command:
$ECLIPSE/eclipse.exe
The first thing the wizard will ask you is to select a workspace for your projects. Select somewhere convenient and let's call it
$WORKSPACE.
After this, you will see the main Eclipse SDK window.
Configuring for JDK 1.5
If your Eclipse came preconfigured like ours, you'll need to select from the main menu:
Window >> Preferences,
then double click to expand the tree view subitem item:
Java >> Installed JREs
This will allow you to click the button:
Add
button to select a new JRE.
Next, expand the tree view item:
Java >> Compiler
and then select from the compliance level pulldown:
5.0
which allows you to run Java 1.5 (see sidebar).
Then select the button at the bottom of the Compiler panel:
Apply
button at the bottom of the Compiler panel. This will pop up a warning dialog telling you the compiler settings changed (I think we knew that -- we just changed them). It then tells you a full rebuild is required and asks you if you want to do it. Select from the popup warning menu the button
No.
We'll build later.
Creating a LingPipe Project
To create a project, select from the main menu:
File >> New >> Project.
This pops up the new project wizard, from which you should select from the list of wizards:
Java Project from Existing Ant Buildfile
from the list of wizards, then click on the button at the bottom of the wizard's window:
Next.
Enter the name LingPipe
into the text field:
Project Name.
Next, provide a path to the Ant Buildfile
directly, or by selecting the button:
Browse...,
which, as the standard UI convention indicates through ellipses
(...), will pop up a new dialog box; in this instance,
a file browser. Navigate and select:
$LINGPIPE/build.xml
where $LINGPIPE is the root directory of the
LingPipe distribution.
Eclipse's wizard will
automatically find the javac task from ant to build LingPipe.
Fixing the Classpath
Eclipse is not smart enough in importing LingPipe's
build.xml file to figure out the two ant targets,
compile and compile-test. To help it out,
select from the main menu:
Project >> Properties,
which pops up a properties dialog box in a separate window. From the tree viewer control in the left panel, choose:
Java Build Path
This pops up the build path panel, from which you need to select the tab:
Libraries
In the libraries tabbed panel that pops up, click the button
Add External JARs,
which will pop up a file selector window. Navigate to and double click
$LINGPIPE/lib/junit-3.8.1.jar
to open. Finally, click the button at the bottom of the properties dialog window:
OK
Now the project is all ready to go.
Exploring LingPipe's Code
Returning to the main Eclipse window, you'll see near the top left a tab:
Package Explorer
It's panel contains a tree viewer, one root item of which you should double click to expand:
Alias-i LingPipe
This tree viewer lets you walk the directory structure of LingPipe, viewing both libs and source code trees.
Package Browsing
Double click on the tree viewer to expand the source:
src
This will display all of the packages in LingPipe.
As you will see, many of these are under
com.aliasi.test.unit packages, which do not
make up part of the standard LingPipe jar
Select a package to expand and double click it:
com.aliasi.util
Now you will see the classes and interface making up the util
package. From this view, select and double click the interface:
Scored.java
This provides an expanded view of the com.aliasi.util.Scored
interface.
It contains two static final constants (both
comparators), and two inner static classes (which are private). You
will also see a method declaration, which you may double click:
score()
This will open the file
$LINGPIPE/src/com/aliasi/util/Scored.java for editing in
the editor panel, showing a tab with the name of the file along the
top. This is an instance of the reverse indexing from components to
the source which is so useful in IDEs. B Scored
interface. Clicking on other components of a class or interface
have the same behavior; they are hot links to the code.
Type Hierarchy Browsing
Before viewing the hierarchy, you need to create it. You may do this from the package browser view just discussed. In the package explorer, right click on
Alias-i LingPipe>
to pop up a context-sensitive menu and select the menu item:
Open Type Hiearchy
This
switches the view from the Package Explorer to
the Hierarchy tab. You'll then see a list of every
class in LingPipe.
One of the more useful aspects of Eclipse is the reverse indexing into code it does from the methods, constants, etc. For instance, right clicking on a class or interface in the package explorer tab, such as
Scored
will pull up a context-senstivie menu from which if you select:
References >> Project,
you will be presented with a list of all of the places in the the code
that refer to the Scored interface. These are shown in
the search tab of a different panel on the main Eclipse SDK window.
Jar Browsing
The jars included in LingPipe's lib directory are
displayed in collapsed form in the package tree viewer. Clicking on
the jar will explose the classes contained in the jar. There should
not only be the main library for Java, the JRE_LIB, but
also the imported LingPipe jars, such as
xml-apis-2.9.0.jar.
Building LingPipe
With our already imported ant build file, Eclipse already knows how to
build our project. Just select from the main menu Project
>> Build All (and start to notice all the keyboard
shortcuts while you're at it). This will pop up a progress window,
and when that's done, you'll likely get hundreds of warnings until we
get around to cleaning up the code so there are no more warnings.