Getting started with Eclipse


Getting started with Eclipse

Here I'm keeping notes on how I get going with Eclipse.

§    Caveat

As of July 2008, I have given up on Eclipse. Each release seems more unstable than the last, and I've gotten tired of finding new ways to stop it from crashing.

Here are my notes on Netbeans: [ Using_Netbeans_with_an_existing_project.html ]

Netbeans is much easier to set up, and it is quite intuitive to a former Eclipse user. It is also pure Java, without the native code bugs of SWT.

If you can afford it, IDEA is even better: [ Idea_notes.html ]

§    My original project

My project is under CVS control, with an ant build.xml, and a directory tree like the following. Let's call my project "foo".
.
|-- build
|   |-- cls
|   |   `-- com
|   |       `-- acme
|   |           `-- foo
|   |-- javadoc
|   `-- obj
|-- data
|-- dist
|   |-- bin
|   |-- doc
|   `-- lib
|-- doc
|-- etc
|-- jar
|-- src
|   |-- com
|   |   `-- acme
|   |       `-- foo
|   |-- cpp
|   `-- scripts
`-- test

The src directory contains all source code for compilation. Everything is under source control. No files created by the build should go in here.

The build, dist, and test directories are created dynamically by the ant build and are not in the CVS repository. Classes, javadocs, and compiled C++ objects are compiled into the build directory. Jars and C++ shared-object archives are created in the dist directory. The dist directory looks exactly like what goes on a release CD. It has everything of interest to a client. The unit tests (JUnit) run inside the test directory and use only files inside the dist directory. Test log files are also formatted into the test directory. An ant clean simply removes these three directories.

The remaining directories are under CVS control and do not change during a build. Some of each may be copied to the dist directory for release. jar contains third-party jar files only, not those created by the build. doc contains human-edited documentation (not javadocs). The build may do some formatting of these for distribution. etc contains runtime configuration files, such as logging properties. The data directory contains small datasets for running tests.

§    Installing Eclipse

First of all, I got the latest milestone build from http://eclipse.org/downloads/index.php with support for Java 1.6. Their last few releases have been great improvements. I've heard of no problems with milestone builds.

I download the linux zip file with the letters "SDK" and "gtk" in the name.

I unzip the distribution in a convenient location like /usr/local/eclipse and create an alias.
alias ecl="eclipse -data $HOME/projects -vmargs -Xmx700m -XX:MaxPermSize=256m"

The -data argument sets the base directory for all projects to a convenient location.

I was warned to increase the VM memory because it is very difficult to clean up after an out-of-memory crash.

The MaxPermSize seems to prevent another common variety of crash: http://www.eclipsezone.com/eclipse/forums/t77021.html This obscure JVM parameter defaults to too small a value. Recent releases of Eclipse are understood to fix this problem.

I also set JAVA_HOME to point to my JDK installation. Eclipse seems to use this to set paths.

§    Basics

  • I start up the GUI and see some big icons for documentation and tutorials.
  • Set defaults for new java projects. Go to the menu bar and select Window -> Preferences -> Java -> Build Path. For the directories, I described earlier, I select the "Folders" button and set "Source folder name" to "src" and set "Output folder name" to "build/cls". Hit "Apply." You might also check the defaults for "Ant." Mine were correct.
  • Set your compiler level. First, go to the menu bar and select Window -> Preferences -> Java -> Editor -> Installed JREs and make sure it is correct. It should be if you defined a JAVA_HOME. Go to the menu bar and select Window -> Preferences -> Java -> Compiler and select "1.6" or whatever as your "Compiler Compliance Level." Hit "OK."

    §    Creating a Java project from new CVS checkout

    §    Configuring the project build

    §    Style preferences

    §    Shortcuts

    The single most useful hotkey is probably F3, to get the declaration of a variable.

    Here are some more

    http://www.javaworld.com/javaworld/jw-08-2005/jw-0829-eclipse.html

    §    Vi plugin

    I've been very happy with the Vrapper plugin for vi editing mode.

    Go to Help -> Install New Software -> Work with: http://vrapper.sourceforge.net/update-site/stable then check the box next to Vrapper and Next and Finish.

    You'll need to restart all of Eclipse, not just the Perspective.

    One installed correctly, you should see a new toolbar option Edit -> Toggle Vrapper.

    To continue to get updates, Go to the menu bar (Window -> Preferences -> Install/Update -> Available Software Sites -> Add ...) and add the Location http://vrapper.sourceforge.net/update-site/stable, if it is not already present.

    §    Miscellaneous

    Bill Harlan, 2004-2006


    Return to parent directory.