Tutorial de Eclipse
Tutorial de Eclipse
Back to top
Eclipse is open source
Open source software is software that is released with a license intended to ensure that certain rights
are granted to users. The most obvious right, of course, is that the source code must be made
available so that users are free to modify and redistribute the software. This protection of users'
rights is accomplished with a device called a copyleft: the software license claims copyright
protection and prohibits distribution unless the user is granted these rights. The copyleft also
requires that any re-distributed software be covered by the same license. Since this, in effect, stands
the purpose of copyright on its head -- using the copyright to grant rights to the user rather than
reserve them for the developer of the software -- copyleft is often described as "all rights reversed."
Much of the fear, uncertainty, and doubt that have been spread about open source software involves
the so-called viral nature of some copyleft licenses -- the idea that if you use open source software
as part of a program you develop, you will lose your intellectual property because the license will
"infect" the proprietary parts you develop. In other words, the license may require that all software
bundled with the open source software, including any newly developed software, must be released
under the same license. While this may be true of the most well-known copyleft license, the GNU
General Public License (under which Linux, for example, is released), there are other licenses that
provide a better balance between commercial and community concerns.
The Open Software Initiative is a non-profit organization that explicitly defines what open source
means and certifies licenses that meet its criteria. Eclipse is licensed under the OSI-approved
Common Public License (CPL) Version 1.0, which "is intended to facilitate the commercial use of
the Program ..." (for a link to the complete text of the Common Public License v1.0, see Resources
later in this article).
Developers who create plug-ins for Eclipse or who use Eclipse as the basis for a software
development application are required to release any Eclipse code that they use or modify under the
CPL, but they are free to license their own additions in any way they like. Proprietary code bundled
with software from Eclipse does not need to be licensed as open source, and the source code does
not need to be made available.
Although most developers will not be using Eclipse to develop plug-ins or to create new products
based on Eclipse, the open source nature of Eclipse is important beyond the mere fact that it makes
Eclipse available for free (and despite the fact that a commercial-friendly license means that plug-
ins can cost money). Open source encourages innovation and provides incentives for developers,
even commercial developers, to contribute code back to the common open source code base. There
are a number of reasons for this, but perhaps the most essential is that the more developers
contribute to the project, the more valuable the project becomes for everyone. As the project
becomes more useful, more developers will use it and create a community around it, like those that
have formed around Apache and Linux.
Back to top
Who is Eclipse?
The Eclipse.org Consortium manages and directs Eclipse's ongoing development. Created by IBM
after reportedly spending $40 million developing Eclipse and releasing it as an open source project,
the Eclipse.org Consortium recruited a number of software tool vendors including Borland, Merant,
Rational, RedHat, SuSE, TogetherSoft, and QNX. Other companies have since joined, including
Hewlett Packard, Fujitsu, and Sybase. These companies each appoint a representative to a Board of
Stewards that determines the direction and scope of the Eclipse project.
At the highest level, the Project Management Committee (PMC) manages the Eclipse project. The
project is divided into subprojects and each of these has a leader. Large subprojects are divided into
components, and each of these also has a leader. At present, most of these managerial roles are
filled by people from the IBM subsidiary that originally developed Eclipse, Object Technology
International (OTI), but as an open source project, anyone is welcome to participate. Responsibility
for any specific piece is earned by contributing to the project.
Now that we've looked at some of the theory, history, and politics behind Eclipse, let's take a look at
the product itself.
Back to top
The Eclipse Workbench
The first time you open Eclipse, you see the following welcome screen:
Back to top
The Java Development Environment (JDE)
To try out the Java development environment, we'll create and run a "Hello, world" application.
Using the Java perspective, right-click on the "Hello" project, and select New=>Class as shown in
Figure 2. In the dialog box that appears, type "Hello" as the class name. Under "Which method
stubs would you like to create?" check "public static void main(String[] args)", and then press
Finish.
Back to top
Additional plug-ins
In addition to plug-ins like the JDT for editing, compiling, and debugging applications, plug-ins are
available that support the complete development process from modeling, build automation, unit
testing, performance testing, version control, and configuration management.
Eclipse comes standard with a plug-in for working with CVS, the open source Concurrent Versions
System for source control. The Team plug-in connects to a CVS server, allowing the members of a
development team to work on a set of source code files without stepping on each other's changes.
Source control from within Eclipse won't be explored here further, because it requires setting up a
CVS server, but the capability for supporting a development team, not just standalone development,
is an important and integral feature of Eclipse.
Just a few of the third-party plug-ins that are either available or have been announced include:
Version control and configuration management
• CVS
• Merant PVCS
• Rational ClearCase
UML modeling
• OMONDO EclipseUML
• Rational XDE (replaces Rose)
• Together WebSphere Studio Edition
Graphics
• Batik SVG
• Macromedia Flash
Web development, HTML, XML
• Macromedia Dreamweaver
• XMLBuddy
Application server integration
• Sysdeo Tomcat launcher
For a more complete list of available plug-ins, see Resources for a link.
Back to top
Example: a UML modeling plug-in
To view an example of a plug-in, and see how it integrates with Eclipse, download the popular
OMONDO EclipseUML (see Resources for a link); you'll need to register, but the plug-in is free.
This plug-in depends on GEF, or the Graphical Editor Framework, another plug-in for Eclipse. GEF
is part of the Tools subproject. To download GEF, go to the Eclipse Web site (see Resources),
select "downloads", and then click the link for the "Tools PMC downloads page". Note you will
need to download the GEF build recommended by OMONDO (GEF version 2.0 for OMONDO
version 1.0.2).
Once downloaded, a plug-in is usually installed by unzipping the download file and copying its
contents to the Eclipse plug-ins directory. In this case, GEF requires that it be unzipped into the
Eclipse directory (it automatically goes into the plug-ins directory from there) while EclipseUML
requires unzipping directly into the plug-ins subdirectory of the Eclipse directory. To be safe, you
might want to unzip each into a temporary directory and copy the directories as appropriate from
there. If Eclipse is running, you'll need to stop and restart it for the plug-ins to be recognized.
Once EclipseUML (and GEF) are installed, you can create a class diagram the same way you create
a Java class file. In the Java perspective, right click on the "Hello" project in the Package Explorer,
and select New=>Other from the pop-up menu. There will be a new option for UML in the left
panel of the New dialog. The free version of EclipseUML only supports class diagrams, so the only
option on the right is UML Class Diagram. Select UML Class Diagram, and type in a name for the
class diagram, such as "Hello":
/** Person.java
* @author david
*/
public class Person {
private String name;
private Address address;
/**
* Returns the address.
* @return Address
*/
public Address getAddress() {
return address;
}
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}
/**
* Sets the address.
* @param address The address to set
*/
public void setAddress(Address address) {
this.address = address;
}
/**
* Sets the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
(I should confess that I only typed in the lines for the name and address attributes. The getter and
setter methods were automatically generated through Eclipse by right-clicking on the source code,
and selecting Source=>Generate Getter and Setter from the pop-up menu.)
Save and close Person.java Hello.ucd.
To create a Java class from the UML, click on the "New class" button on the toolbar at the top of
the class diagram window, the third button from the left, and then click on the class diagram. When
the New class wizard opens, type in Address as the class name and press Finish.
You can add attributes to the class by right-clicking on the class name and selecting
New=>Attribute. In the New attribute dialog box, enter the attribute name, type, and visibility.
Add methods by right-clicking on the class name and selecting New=>Method.
As you change the diagram, the Source Editor window below the diagram will reflect the changes.
Finally, you can diagram the relationship between the classes by clicking on the Association button
(fifth from the left) and drawing a line from the Person class to the Address class. This will bring up
another dialog box where the association properties can be entered (refer to the EclipseUML help
for more information about the required information). The diagram should look something like this:
Figure 9. Association
This UML plug-in demonstrates several characteristics that are typical of Eclipse plug-ins. First, it
shows the tight integration between tools. It is never obvious that there are multiple components at
work; the integration with the Eclipse Platform and the JDT are seamless. For example, when the
Person class was created, it displayed syntax errors because one of its attributes, Address, was
undefined. These went away once the Address class was created in the UML diagram.
Another characteristic is EclipseUML's ability to build on functionality offered by other plug-ins --
in this case, the GEF, which provides tools for developing visual editors.
Yet another characteristic involves the way the EclipseUML plug-in is distributed using several
tiers of functionality. The basic plug-in, which supports class diagrams, is free, but more
sophisticated versions are available for a fee.
Back to top
Eclipse Platform architecture
The Eclipse Platform is a framework with a powerful set of services that support plug-ins, such as
JDT and the Plug-in Development Environment. It consists of several major components: the
Platform runtime, Workspace, Workbench, Team Support, and Help.
Platform
The Platform runtime is the kernel that discovers at start-up what plug-ins are installed and creates a
registry of information about them. To reduce start-up time and resource usage, it does not load any
plug-in until it is actually needed. Except for the kernel, everything else is implemented as a plug-
in.
Workspace
The Workspace is the plug-in responsible for managing the user's resources. This includes the
projects the user creates, the files in those projects, and changes to files and other resources. The
Workspace is also responsible for notifying other interested plug-ins about resource changes, such
as files that are created, deleted, or changed.
Workbench
The Workbench provides Eclipse with a user interface. It is built using the Standard Widget Toolkit
(SWT) -- a non-standard alternative to Java's Swing/AWT GUI API -- and a higher-level API,
JFace, built on top of SWT that provides user interface components.
The SWT has proven to be the most controversial part of Eclipse. SWT is more closely mapped to
the native graphics capabilities of the underlying operating system than Swing or AWT, which not
only makes SWT faster, but also allows Java programs to have a look and feel more like native
applications. The use of this new GUI API could limit the portability of the Eclipse workbench, but
SWT ports for the most popular operating systems are already available.
The use of SWT by Eclipse affects only the portability of Eclipse itself -- not any Java applications
built using Eclipse, unless they use SWT instead of Swing/AWT.
Team support
The team support component is responsible for providing support for version control and
configuration management. It adds views as necessary to allow the user to interact with whatever
version control system (if any) is being used. Most plug-ins do not need to interact with the team
support component unless they provide version control services.
Help
The help component parallels the extensibility of the Eclipse Platform itself. In the same way that
plug-ins add functionality to Eclipse, help provides an add-on navigation structure that allows tools
to add documentation in the form of HTML files.