 | Level: Intermediate Genady Beryozkin (mail@genady.org), Software Developer, Content Developer
21 Aug 2007 Eclipse is a new world for Microsoft® Visual Studio® developers, and getting
started with Eclipse can be confusing. New concepts, such as plug-in architecture,
workspace-centric project structure, and automatic build can seem counterintuitive at
first. Learn about these and other differences between the two environments, so that
you can begin to feel at home with Eclipse.
All integrated development environments (IDEs) share similarities because they're all
built for the same purpose. But they have differences, too. Some of these can be
attributed to application domains, but others result from the IDE design.
Obviously, Microsoft Visual Studio and Eclipse differ: The Java™ programming
language is different from C/C++/.NET, and Java was the first language supported by
Eclipse. The two are also different because Eclipse aims to be an IDE for
"everything and nothing in particular," introducing more generic and customizable
features. Eclipse is also available on more operating systems. However, our intent is
not to enumerate all the differences between Eclipse and Visual Studio.
Without being too philosophic about IDE design, this article presents the main
differences between these IDEs. It's intended for anybody who has been using Visual
Studio for a while and is beginning to use Eclipse. This article doesn't teach Java
programming in Eclipse and doesn't focus on Java-specific features (a good tutorial is
listed in Resources). Rather, it discusses the differences in general.
The Eclipse workspace
 |
The workspace directory
The Eclipse workspace is a directory in the filesystem that contains a special
.metadata subdirectory. The .metadata directory contains all the workspace's private
information, such as settings, caches, etc. Normally, you shouldn't modify any files in
the .metadata directory. The workspace directory is also the default location for new projects in Eclipse.
|
|
Generally speaking, the Eclipse workspace serves the same purpose as a Visual Studio
solution: It organizes top-level projects, folders, and files in a hierarchical
structure. However, there are some major differences. A Visual Studio solution merely
lists the projects it contains with their interdependencies, configurations,
version-control information, etc.
The Eclipse workspace does much more than that. It
manages most of the nonproject information, such as global preferences, windows
layout, and search and navigation history. Eclipse can't start without a workspace, and
you can't close a workspace the same way you can close a Visual Studio solution.
Although it is possible to switch workspaces in Eclipse, many users use a single
workspace that contains all their projects.
Project structure
 |
Origins of the Eclipse project structure
The strict correspondence between a project's structure and its filesystem layout was
probably influenced by the mandatory correspondence between Java packages and their
layout on the filesystem. In the Java language, the class p1.p2.p3.Class1 must reside
in the directory p1/p2/p3.
Visual Studio languages (C/C++/C#, and even J#) don't mandate such a directory
structure. Consequently, the correspondence between the project's structure and its
filesystem layout isn't that strict in Visual Studio.
|
|
Eclipse projects differ from Visual Studio projects in the way they interact with the
underlying filesystem. In Visual Studio, a project isn't strongly connected to its
layout on the filesystem: You can add a file from c:\temp\ to a project located in
d:\work, and Visual Studio records the reference to a new file and opens it like any
other file. Folders (like "header files") don't correspond to filesystem folders
(internally, such folders are called filters).
In Eclipse, the structure of a project's elements must correspond to their layout in
the underlying filesystem. For example, if the Eclipse project HelloWorld (see Figure
1) is located at c:\eclipse\workspace\HelloWorld, then README.TXT is located at c:\eclipse\workspace\HelloWorld\src\README.TXT.
Figure 1. A simple HelloWorld project
Eclipse also wants to be in sync with the files under the project directory. If you
delete a file or a folder in Eclipse, it disappears from the filesystem. However, when
you add or delete the same file using Windows® Explorer, the related
resource in Eclipse becomes out of sync, which may upset Eclipse during some
operations. In such a case, you should manually refresh the project by choosing
Refresh from the project's right-click menu. You can tell Eclipse to
automatically synchronize with the filesystem by selecting Refresh automatically
option in the Eclipse preferences.
Linking resources into Eclipse
The strict workspace structure was how things began. Although projects could be stored
outside the workspace directory, early Eclipse versions couldn't even open an external
file (today, you choose File > Open File). UNIX® users were lucky
because they could emulate a flexible project structure using symbolic links, but
Windows users didn't have such privileges. Today, Eclipse supports linked
resources at the IDE level.
Linked resources in Eclipse behave much like UNIX symbolic links. For example, to add a
large test input file to the project without copying it from its original location,
choose File > New > File, and, in the window that opens, click
Advanced (see Figure 2). After they're added, linked resources are decorated
with a small arrow over their icons (see Figure 3).
Figure 2. Adding a linked file
Figure 3. Linked file in the HelloWorld project
Tip: Using linked resources to improve performance
 |
Using a linked folder as a Java output folder
To use a linked folder as a Java output folder for an existing project, you first need
to make sure your project uses separate folders for source and .class files (if it
doesn't, you need to move the source files to a separate folder). Then, open the
Navigator view, turn off the automatic build, delete the old
output folder, create a new linked folder with the same name, turn the automatic build
back on, and rebuild the project with Project > Clean.
|
|
Linked folders can be useful when you're dealing with large projects that reside on
remote locations, such as file servers or ClearCase dynamic views. Although source
files can benefit from being properly backed up and otherwise managed, there are few
reasons to store the generated .class files on such remote storage. In projects with
more than a few hundred source files, you can dramatically improve the performance of
many operations if you store the generated files on the local machine.
In Visual Studio C++ projects, you can improve build performance by setting the
intermediate directory to a local location. In Eclipse, you can achieve the same effect
by using a linked output folder that points to a directory on the local machine.
See Resources for additional information, including how to use
variables to define platform-dependent link targets, such as using a temporary
directory at /tmp on UNIX and at c:\temp on Windows.
Reducing clutter with working sets
As mentioned, many developers load all their projects into a single Eclipse workspace.
It's convenient, but it can sometimes create too much clutter. In addition to closing
unnecessary projects, you can define working sets: groups of elements (projects,
folders, classes, etc.). Eclipse can use working sets in different views (such as
Package Explorer) and operations (like searching). See Resources for additional information.
The local history
One of Eclipse's coolest features — and one that Visual Studio doesn't
have — is the
local history. Each time you change a file, class, or method, Eclipse records the
change in its local history. Then, you can compare a file to what it was a few
minutes, hours, or days ago. If a file is deleted, invoking Restore from Local
History from its parent's context menu can bring it back.
The local history isn't a version-control replacement. It's more like a super-undo
engine with configurable limits for the number of history days and the allotted storage capacity.
Building projects
Contrary to the Visual Studio approach, in which a project has a single project type
(C++/C#/J#), Eclipse projects can have zero, one, or multiple natures. For
example, Java projects in Eclipse have a Java nature, and Dynamic Web projects (created
using Eclipse WTP; see Resources) have a Java and a (metaphoric) Web
nature. A project nature defines a list of builders that run when the project is
being built. For example, the Java nature adds a builder that compiles Java source
files into .class files, and the Web nature adds a builder that validates the XML and HTML files.
Building projects automatically
 |
Building non-Java projects
Automatic build is perfect for Java projects because the internal incremental
compiler (Eclipse doesn't use javac) can handle small code changes quickly. Although
builds run in the background, for project types (such as CDT
projects), in which a small update can trigger lengthy compilation, you may prefer to
turn off automatic build (Project > Build Automatically). You can then run
the build manually (Project > Build All) or let Eclipse do the build before
running an application.
|
|
At their first encounter with Eclipse, many look for the Build command. But to their surprise, either they can't find it or they find it's disabled.
That's because unlike Visual Studio and some other IDEs, Eclipse has an automatic
build feature. In Java projects, every time a Java file is modified, Eclipse
compiles the relevant files, including files indirectly affected by the
change. Automatic build is a great way to quickly discover compilation errors that
affect other files. Many operations, such as Java search, rely on these build results.
Customized builds
Often — mainly for C++ projects — Visual Studio projects use custom build steps to
perform nonstandard build tasks. Custom build commands are plain command-line
instructions in Visual Studio projects. Eclipse, on the other hand, can run stand-alone
programs and Ant build scripts. For example, you can use an Ant script to build and
deploy a Java Archive (JAR) file containing the project's classes whenever a project is
rebuilt. An editor for Ant's build.xml files is included.
You can configure custom project builders on the Builders page in the project's
properties window, and you can define and run global scripts by choosing Run > External Tools.
Run and debug
 |
Languages and entry points
Visual Studio languages (C++/C#) can have only one entry point per executable, which
is determined at link time. The Java programming language allows multiple entry
points (main methods) at compile time. The entry point is
determined on the command line when the program is launched.
|
|
Eclipse doesn't have the notion of startup projects, as does Visual Studio. The
difference can be attributed to language differences, but Visual Studio
further restricts its users by generating a single executable per project and allowing
different launch parameters, such as command-line arguments, only for different project
configurations. Managing multiple configurations just for the sake of having different
command-line arguments is a bad idea in most situations.
Eclipse uses launch configurations to collect the parameters used to launch an
application. For Java programs, the main class name and the command-line arguments are
such parameters. You can have separate launch configurations for any class with a main() method in the project. A new configuration is automatically
created when you launch an application with a new main class using the Run > Run
As command. You can also use the Run window (Run > Run) to create and
delete launch configurations.
By default, launch configurations are local to the workspace and aren't part of the
project, which means they aren't shared with other team members. To save the launch
configuration in the project, use the Common tab of the Run window, as shown
below.
Figure 4. Changing the location of launch configuration
The Debug perspective
Eclipse has no debug mode — just the Debug perspective you can switch to and
from. The main Debug view lists all the programs being run or debugged and lets you
debug several programs at the same time, which is a little more difficult to do in
Visual Studio. Read "Debugging with the Eclipse Platform" (see Resources) to
learn more about the debugging features Eclipse has to offer.
Eclipse plug-ins
In addition to being a great free open source Java IDE, the most important feature of
Eclipse — which accounts for much of its success — is its open
extensibility architecture. Most Eclipse features can be extended or are accepting
contributions from plug-ins. In fact, many Eclipse features use the same extensibility
architecture that is available for the general public.
The business-friendly open source license Eclipse uses encourages the development of
commercial and open source plug-ins. No wonder more than 800 plug-ins are listed on the
official plug-in marketplace at Eclipse Plugin Central.
In addition to plug-ins, which integrate into an existing Eclipse installation, some
companies have built full-featured IDEs on top of Eclipse, including all IBM®
Rational® tools, CodeGear JBuilder 2007, and Genuitec MyEclipse. Typically, these
products offer tools for modeling, Web development, and visual design. See Resources for products and plug-in directories.
Additional Eclipse projects
The basic Eclipse software development kit (SDK) contains only the Java IDE. Toolkits
for other languages (C/C++, PHP), modeling tools, and additional extensions are being
developed under the Eclipse umbrella and can be installed as Eclipse plug-ins. See
Resources for more information about Europa, the latest simultaneous release of the top 21 Eclipse
projects in 2007, and Callisto, the previous release of top 10 projects in June 2006.
The Update Manager
Whenever you download Eclipse for the first time or as an upgrade, you get a plain
compressed file you extract into an empty directory, with no installer to perform any
configuration or to create a desktop shortcut. However, for plug-ins, Eclipse has the
Update Manager (Help > Software Updates), which manages both installations
and updates. It can also enable and disable plug-ins, similar to what the Add-in
Manager does in Visual Studio.
The Update Manager installs or updates plug-ins from update sites (either
local or on the Web). To install new plug-ins, you must find the update site URL on the
vendor's Web site and manually enter it in the Update Manager window. (Some vendors
have built full-featured installers that interact with the update manager behind the scenes.)
To a lesser extent, Eclipse supports installing plug-ins by manually copying them into
the appropriate directories. This method isn't recommended, and it can cause
inconsistency in the Eclipse configuration. See "Basic
troubleshooting" for more information.
When you need help
If you're new to Eclipse, you'll probably have some questions. And after using it for a
while, you may discover a couple of bugs or may wish to suggest new features. This
section surveys the different support options.
Basic troubleshooting
Everybody knows that sometimes, the IDE can misbehave. With Visual Studio, you can
reset everything to the factory state by typing devenv
/setup at the command prompt. Eclipse provides a similar command-line switch.
Running eclipse.exe -clean at the command line rebuilds most
information about the installed plug-ins. The -clean option
may be useful if you've installed a new plug-in and it refuses to show up.
When Eclipse misbehaves, you may also want to check the error log. To open the Error
Log view, choose Window > Show View > Error Log. The raw log is located in
the <workspace dir>/.metadata/.log file.
Newsgroups
If you've been working with Microsoft products, you know that you can get help on the
Microsoft Developer Network (MSDN) forums and newsgroups. The Eclipse community has its own newsgroups (see Resources), and many Eclipse regulars are there to help you out.
Report bugs and ask for new features
Unlike the Microsoft feedback feature on the Microsoft Connect Web site, which is aimed
at providing customer support, Eclipse Bugs is the actual bug-tracking system used
by Eclipse developers. With Eclipse Bugs, you can not only search, report and vote
on bugs but also add yourself as a CC on somebody else's bug, see who is assigned to
fix it, learn the version in which it should be fixed, and much more. You can post
feature requests using the same interface (see Resources).
Premium support
In addition to the open source spirit of Eclipse Bugs and community help, some companies
need a commercial level of support for their development teams. If you purchase a
product that is built on top of Eclipse, its vendor should provide support for the
product, including the underlying Eclipse components. If you use the basic Eclipse SDK,
you can check the IBM Rational Elite Support for Eclipse program with a worldwide
24x7x365 support plan.
Conclusion
We have discussed how Eclipse approaches some common IDE principles and
tasks. The workspace-centric approach and project structure on one hand and the great
flexibility of the UI design and launch configurations on the other make Eclipse
unique in its IDE design. And the open-extensibility architecture makes Eclipse a
platform for a great variety of third-party plug-ins and products.
If you haven't done so yet, read the "Eclipse for
Visual Studio developers" tutorial (see Resources), which gives a good introduction to Java
development in Eclipse. However, Eclipse isn't all about the Java programming language.
Check the Callisto and Europa releases for additional Eclipse
projects, such as the C++ IDE. Then visit Eclipse Plugin Central and
download some popular Eclipse plug-ins.
Resources Learn
Get products and technologies
Discuss
-
Visit EclipseZone, an online community by and
for Eclipse users.
-
Visit Planet Eclipse, a collection of Eclipse blogs.
-
The Eclipse Platform newsgroups should be your first stop to discuss questions regarding Eclipse. (Selecting this will launch your default Usenet news reader application and open eclipse.platform.)
-
The Eclipse newsgroups has many resources for people interested in using and extending Eclipse.
-
Participate in developerWorks blogs and get involved in the developerWorks community.
About the author  | 
|  | Genady Beryozkin is a software developer with more than nine years of experience. He
used Visual Studio for various C++ and C# projects, and has been using Eclipse for Java
development since even before its initial 1.0 release in 2001. In 2002, he created the
RMI plug-in for Eclipse, which helps
developers to effectively develop, debug, and run applications that use the Java Remote
Method Invocation (RMI) technology. He holds a bachelor's (summa cum laude) and
a master's degree in computer science from Technion, Haifa, Israel. |
Rate this page
|  |