The current version is 7.0.1 Last revised/verified: 2011-12-14.
A popular free IDE (Integrated Development Environment) for writing Java. It does refactoring. It was originally developed by IBM (International Business Machines). It is an enormous
project encompassing more than just an IDE. Internally it uses SWT (Standard Widget Toolkit), IBM is a crack at tackling the same problem
Swing does, but more streamlined. You have the option of using AWT (Advanced Windowing Toolkit), Swing or SWT in your own code. Eclipse is Jon
Skeet’s favourite IDE.
I used it for a while several years ago the moved to IntelliJ. It allows plug-ins for extra
functionality. It uses its own compiler that lets it do incremental compiles and hot swapping of code during
debugging. There are dozens of different versions of it, each targeting a different type of developer, including C++ and JavaScript.
Advantages
- Free and Open Source
- Comes in 32-bit and 64-bit versions
- It starts in 19 seconds. I would like this faster, but it pretty good compared with what I put up with in past.
Disadvantages
- There are dozens of downloads with little guidance on what you need.
- Slow to load
- Hard to get started. It is not clear what a project is or how the directory structure works.
- The menus are full of references to undefined features with meaningless names.
Eclipse Is A SCID (Source Code In Database)
Eclipse is an almost a SCID.
You may have no interest in how Eclipse works under the hood, but you had better understand at least as much
as I am about to explain. Eclipse has its own copy of the source files. It also compiles them on the fly, as you
type. This is how it can navigate so quickly, do global renames, refactor, find references and declarations
instantly, compile instantly and undo changes, plugins etc. It does not use Javac.exe at
all (except in an ant build). It tokenizes your source as you type, checks for errors and
uses its own incremental/background compiler when you hit save.
Every time you click save at saves a conventional *.java
copy of the class source on disk along with a corresponding compiled *.class file.
However, if you modify one of those files, delete it, rename etc., sometimes nothing happens. It is as if Eclipse
were oblivious to your changes. The true copy of your program is in RAM (Random Access Memory). Don’t touch Eclipse’s
*.java files while Eclipse is running.
Instead of meddling with Eclipse’s *.java files, export, fix with your conventional tools and editors and the import the
back again.
Import is the trickiest feature of Eclipse. Check after every import that your new source overrode the old and
went into the correct place. You can drag and drop to the correct place if it missed. It is so easy to mess up
and effectively lose all the work you did outside Eclipse. If you screw up, you can compare Eclipse files with
your exported ones, correct your copy of the files with SlickEdit Diffzilla™,
and reimport them. Again, there is no point in using Diffzilla to directly fix the Eclipse files. I suggest you
experiment with a practice set of files till you are sure you get the hang of import, export and refresh. The full
story is more complicated than I presented here. You can make changes to the source files if you know what you
are doing.
Eclipse itself is written in Java, and you will notice a copy of
javaw.exe running while it is. It is good example of just how polished a Java app can
be. Show it to someone the next time they tell you there are no real apps in Java.
Downloading
Eclipse is a 103 MB download. You likely want the release candidate, not the latest build. Eclipse has no
installer. You just unzip it to a directory of your choice then create a shortcut to
eclipse.exe you can add to menus or the desktop. It uses IE to
display its online help files. You might want to set up a bat file like this to launch eclipse.exe. Windows
shortcuts are not bright enough to include command line parameters. You can tweak the parameters for maximal
speed.
Plug-Ins
Much of the popularity comes from the way Eclipse is designed like a Lego set where can add or replace pieces of
it. Some of the hundreds of plug-ins available are available from:
Though Eclipse is free, the plug-ins are not necessarily free. For example BEA Workshop a
plug-in to handle JSP, Struts, JSF and
Hibernate is .
Directory Structure
In eclipse terminology a project is a not a package, but a related group of packages.
If the project were called savetheworld, and my package were called com.mindprod.stopbush, then the *.java files it generates would live in
E:\ecwork\savetheworld\com\mindprod\stopbush. They are thus fully accessible by
ordinary text editors and other tools, but as I warned later, don’t modify them when Eclipse is
running.
Tips
- If you accidentally close toolbars and Control Panels of various sorts, you can get them back again with
Windows ⇒ show view.
- Ant is built into Eclipse. To get at it, click Windows ⇒ show view ⇒
Ant
- You set and remove breakpoints by double clicking in the margin to the left of the source code line. You
can find things out like that most easily by clicking Help ⇒ Dynamic Help which
gives context- sensitive help. The other help is difficult to find anything in. To examine values of variables
during debugging you just hover your cursor over them. This is not your grandmother’s debugger.
- To configure the code formatter, there are scores of places you have to individually tell it how you like
your space before and after ( x ) done — once for every
conceivable possible context. Don’t give up. Eventually it will format your code exactly as you like it,
even as you type. Then you can do a global reformat of your entire project to your finely tuned
specification.
- the left and right margins are full of marvels taking up very little space. Hover and click to discover
what they do.
- You can easily inadvertently reconfigure your system by dragging the top left corner of any panel to any
place.
- To create a jar, you must export a jar. Eclipse does a poor job of building jars,
foolishly including all sorts of classes not needed. It pays no attention to dependencies. It does not even
insert the Main-Class entry in the manifest, much less list the contents or sign the
jars. I solve this by exporting the project and building with Ant after it is debugged.
- The error messages are not what you are used to. Just look where it is putting squiggles as you type. That
is a spot with an error. Fix them as you go, right away!. It is much harder to sort out problems after
you let them pile up.
- To exclude a file from being considered for compilation, you must exclude it from the build path. Use the
build path ⇒ exclude ⇒ browse to select the file. If you type it, remember
no dots, use / and a trailing / for a directory.
- To view references or definitions, you don’t just right click on an
identifier. You must first double left click to select the whole word, then
right click. I would call that a bug, until someone explains to me why it has to be
that way.
- In Eclipse, you enable assertions by using theJava version 1.4 or later level compiler then
click run ⇒ arguments ⇒ VM arguments then enter -ea. There is no special checkbox to tick.
- In the Eclipse editor, F3 does not mean repeat-find the way it does in
nearly every other Windows editor. You can rectify that by clicking Window ⇒
Preferences ⇒ General ⇒ Keys ⇒ View (Category: Edit, Command: Find Next) ⇒ Edit ⇒
Key.
- To use SWT, you need to download an additional swt.jar and some DLLs.
- It is possible to natively compile
Eclipse itself using JET (Just Enough Time) for extra speed.
- To see the Javadoc for anything in rendered HTML (Hypertext Markup Language), (including your own code), highlight a reference and
click window ⇒ show view ⇒ Javadoc.
- Learn to use the package outline to navigate around your code rather that scrolling or search. You also
have the show declaration and show references.
- Eclipse won’t tidy/reformat your code if there is even the tiniest error, even though that is when
you most need the reformatter to help you find the unbalanced { or ( etc. So use the reformatter often. Save
often to trigger a new round of error messages. Fix errors as soon as Eclipse discovers them. If you
procrastinate, you will have a mess on your hands and Eclipse will refuse to help you clean it up.
- I have not yet found out how to get Eclipse to work in column mode. In SlickEdit®, you just right-click to move rectangular blocks of text, delete
rectangular blocks of text, or limit global operations to a rectangular block. In IntelliJ, you turn on column
mode. It the meantime, I just copy a file back to SlickEdit, and work there, then return. Similarly I have not
found an equivalent of SlickEdit DiffZilla® to intelligently compare two pieces of code for differences.
Again, I just hop back to SlickEdit. For safely, on the Eclipse side, I save and close, though I don’t
usually shutdown Eclipse entirely, do my work outside Eclipse, then do an Eclipse refresh. For smaller bits of
work, I just cut and paste.
- One of the slickest things about Eclipse (and IntelliJ) is the way it breaks String literals for you. If
you had a String literal like this:
"Please take your purchase of 12 apples to the counter."
Put you cursor just before the 12 and hit enter then just after and hit enter. The code transforms to:
"Please take your purchase of "
+ "12"
+ " apples to the counter."
You can then, in a twinkling, change that to more generic code:
"Please take your purchase of "
+ appleCount
+ " apples to the counter."
Unfortunately, Eclipse is not as clever about gluing String literals back
together. Further, it is not smart enough to insert the backslashes needed to deal with embedded quotes.
Upgrading to Eclipse 3.1.1 from 3.0.1
Click Help ⇒ Software Updates ⇒ Find and install ⇒ Search for new
features
Then add a new remote site with label of Eclipse SDK (Software Development Kit) 3.1.1 Updates and an address of
http://update.eclipse.org/updates/3.1
Then tick the new site, and select finished button.