Parent page: Programming Applications

Introduction

Eclipse is an Integrated Development Environment or IDE. The Eclipse was originally created by IBM, but the Eclipse Foundation has since taken over direction and development of the project. Eclipse started out as a Java IDE, but has since grown into much more.

Installation

Ubuntu 10.04 and up

Eclipse 3.5.2 is available as a standard package (eclipse) in the Universe repository, via any package manager in Ubuntu releases 10.04, 10.10, and 11.04. In 11.10, Eclipse version 3.7.0 is available.

Note: To install plugins not available in Package Manager, you'll need to install them in user mode. Do not run Eclipse as root to install plugins.

Eclipse and Sun Java

To install the Sun Microsystems JDK, install the sun-java6-jdk package from the multiverse repository.

By default, the Eclipse which is packaged with Ubuntu runs with the GCJ JVM and not the JVM supplied by Sun Microsystems even if you have installed the Sun Microsystems version.

Note: If you're using Ubuntu 6.06 (Dapper) you'll need to install sun-java6-jdk from the dapper-backports Multiverse repository. Please take a look at UbuntuBackports for more information on using backport repositories.

In order to load eclipse with the Sun JVM, edit the /etc/eclipse/java_home file. [Note from one reader: I did not have to do this step, and I did not have an /etc/eclipse/java_home file, but my eclipse still seemed to use the correct Sun jvm. I do not know know if I somehow did it some other way when installing a different tool that uses eclipse. I am on Ubuntu 10.04. -- DBooth]

  • Add the path of the Sun JVM above the GCJ JVM entry.

/usr/lib/jvm/java-6-sun
/usr/lib/jvm/java-gcj
  [...]
  • To ensure that the change has happened, open Eclipse and click on Help -> About Eclipse SDK -> Installation Details -> Configuration and look for this line:

  [...]
-vm
/usr/lib/jvm/java-6-sun/bin/java
  [...]

As an added bonus, you may also enjoy a speed gain after doing this.

Sun JVM System Wide

You may also want to use the Sun JVM system-wide. Enabling the Sun JVM is a snap using update-java-alternatives.

  • First, find out which versions of Java you have installed through Ubuntu.

sudo update-java-alternatives --list

output:

   java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun
   java-6-sun 63 /usr/lib/jvm/java-6-sun
  • Next, specify the one you would like as the default.

sudo update-java-alternatives --set java-6-sun

Note: The JVMs listed may differ depending on the version of Ubuntu you're using and the setup of your system. The important thing is to choose the JVM with sun in the title.

Using Sun Java as the Default JRE for Eclipse Projects

To use the java-6-sun as the default JRE within Eclipse and to have it used in the build path of Java projects, click on Window -> Preferences -> Java -> Installed JREs and you will see the current JRE's available to Eclipse. To add java-6-sun click the Add... button. A dialog window will come up with configuration options. First set the JRE home directory by clicking the Browse button and navigating to /usr/lib/jvm/java-6-sun. After selecting this location, the rest of the fields should be filled out automatically. Hit OK, and back in the Installed JREs area, place a check box next to java-6-sun to set it as the Eclipse default JRE.

  • Note: This is already set in Ubuntu 7.10 (Gutsy)

Java3d

Java3d is now supported for use with Eclipse on Ubuntu, see Java3dUbuntu.

Plugins

One of the great features of Eclipse is the wide variety of plugins available for the platform. See Eclipse Plugin Central for details on individual plugins. One of the simplest ways to install Eclipse plugins is through the Update Manager, accessed in Eclipse by selecting Help -> Software Updates -> Find and Install.

Plugin Installation Example

In this example we'll install the RDT (Ruby Development Tools) plugin. This plugin will give Eclipse support for the Ruby programming language.

To install RDT:

  1. Open Eclipse and click on Help -> Software Updates -> Find and Install. This will bring up a dialog allowing you to choose updates to currently installed features or find new features to install.

  2. Choose Search for new features to install -> Next.

  3. Click the New Remote Site button. A dialog opens allowing you to input the location of the plugin you wish to install.

  4. In the Name: box, place RDT (or Ruby if that's more descriptive).

  5. In URL: type http://updatesite.rubypeople.org/release. Then click Ok.

    • You should now see RDT in the list of Sites to include in search: box.

  6. Click on Finish

  7. A dialog to install RDT should now appear. Click the checkbox next to RDT in the Select features to install: area.

  8. Click Next -> Accept the License Agreement -> Next -> Finish

  9. A Feature Verification dialog will appear click Install All.

  10. After the plugin installs click Yes to restart Eclipse.

That's all there is to it you can now create Ruby projects and enjoy all the features of the Eclipse IDE.

Note: Most plugins will have a link to the url that you can paste into the udpate manager.

Other Plugin Guides

  • EclipseWebTools - The Web Tools Project provides functionality for web development.

  • See EclipsePDT for instructions installing the PDT plugin (PHP Development Tools). Eclipse 3.3 recommended

    • PHPEclipse is another option as a PHP development environment. This is definitely useful if you're using Eclipse 3.2 and older.

  • BzrEclipse is a plugin that enables Bazaar version control system support.

  • See EclipseSubversion for instructions installing the Subclipse plugin.

Plugin Troubleshooting

Some plugins do not seem to function properly when running Eclipse normally, such as BIRT. Running Eclipse with the following options may fix the plugin:

eclipse -vm $JAVA_HOME/bin/java -ws gtk

User installation

Use this method if you want Eclipse available only for yourself, or if you do not have root access to the computer. It is also useful for those who would like to install newer versions of Eclipse.

Download Eclipse

Open a web browser and go to http://www.eclipse.org/downloads/. There are several different bundles of Eclipse geared toward the different types of software development. You could take a basic Eclipse installation and manually build it into any one of these bundles. They are provided pre-bundled as a convenience for the developer. When in doubt, download the "Eclipse Classic" bundle. It is the most traditional bundle of Eclipse on the list. Select the Linux 32bit package, or 64bit if you're on an x86_64 system.

Preparing your system

We will set up a few folders for Eclipse in your home directory and unpack the Eclipse package into those folders.

Make an opt folder in your home directory:

$ mkdir ~/opt

Change directory to the folder where your browser downloaded the Eclipse package to. Then unpack Eclipse into the opt folder:

$ cd {directory where your browser downloaded the package to}
$ tar -zxvf eclipse-SDK-3.4.1-linux-gtk.tar.gz && mv eclipse ~/opt

Make a bin folder in your home directory, this will be used for the startup script:

$ mkdir ~/bin

Next create an executable for Eclipe at ~/bin/eclipse with your favorite text editor by typing vi ~/bin/eclipse or nano ~/bin/eclipse into the command line. Add the following content:

export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"
export ECLIPSE_HOME="$HOME/opt/eclipse"

$ECLIPSE_HOME/eclipse $*

Finally, allow the script to be executed:

$ chmod +x ~/bin/eclipse

HINT: If you are a gtk user and experience problems with the mouse buttons you should try add an export:

export GDK_NATIVE_WINDOWS=true

to the starter file.

You can now execute that file to start up Eclipse.

Gnome icon

On Unity

See this answer on AskUbuntu to learn how to add Eclipse to the Unity launcher.

Prior to Unity

  • Create a new launcher on the desktop (right click on the desktop -> Create Launcher) or on a panel (right click on a panel -> Add to Panel -> Custom Application Launcher)

    • Name: Eclipse Platform

    • Command: /home/<your username>/opt/eclipse/eclipse

    • Icon: /home/<your username>/opt/eclipse/icon.xpm

General Troubleshooting

Below are some reported errors and the appropriate fixes

Eclipse + Ubuntu = 100% CPU

It seems that on Ubuntu Eclipse needs to be a CPU hungry beast. See for example https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/334991. It seems that issue can be fixed by using a different theme. Another yet undocumented problem is that on Subversion commit it can take 100% CPU. The workaround is to create a new project and remove the old project.

No Java Virtual Machine found

If installing Eclipse seems to work, but trying to run it results only in the following error message:

A Java Runtime Environment (JRE) or Java Development Kit (JDK)
must be available in order to run Eclipse. No Java virtual machine
was found after searching the following locations:
/usr/lib/j2sdk1.4-sun/bin/java

You either have no Java Virtual Machine installed or Eclipse cannot find it. Above on this page it shows that you can check what versions of java are installed by running the following command:

sudo update-java-alternatives --list

If the output of that is

java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk

or something similar, then Eclipse cannot find your JVM. To fix this, you must add the location of your JVM to /etc/eclipse/java_home. Run this command:

gksudo gedit /etc/eclipse/java_home

For the following two commands, replace /usr/lib/jvm/java-6-openjdk with whatever was the 3rd output of update-java-alternatives --list. Now, on a line right before /usr/lib/jvm/java-gcj, type the following:

/usr/lib/jvm/java-6-openjdk 

The file should now look like this:

# This file determines the search order the Eclipse Platform uses to find a
# compatible JAVA_HOME. This setting may be overridden on a per-user basis by
# altering the JAVA_HOME setting in ~/.eclipse/eclipserc.

#/usr/lib/jvm/java-7-icedtea
/usr/lib/jvm/java-6-openjdk   
/usr/lib/jvm/java-gcj
...

If the output of that is just awk errors about missing /usr/lib/jvm/*.jinfo files, it appears there are no Java Virtual Machines installed, and you could install one (and generally fix this error) by running:

sudo apt-get install sun-java6-jdk

During the installation you must agree to the Sun license. Check and see if Eclipse launches normally now.

If it still reports the same error as above after installation of a JVM and running your "... --list" command above now results in output like:

  • java-6-sun 63 /usr/lib/jvm/java-6-sun

Make sure that the detected directory (the /usr/lib/jvm/java-6-sun part) appears as the first line without a "#" in front of it in:

sudo gedit /etc/eclipse/java_home

This should allow Eclipse to find your JVM.

The Eclipse executable launcher was unable to locate its companion startup.jar

If the following error is encountered when running eclipse from the launcher:

The Eclipse executable launcher was unable to locate its companion startup.jar file (in the same directory as the executable)

Edit /usr/bin/eclipse with a text editor (e.g sudo gedit /usr/bin/eclipse) and change the content to the following:

# Eclipse startup script
# JPackage Project <http://www.jpackage.org/>
# $Id$

ECLIPSE_OPTS=""
VM_OPTS=""

# Source system prefs
if [ -r /etc/eclipse.conf ] ; then
  . /etc/eclipse.conf
fi

# Source user prefs
if [ -r $HOME/.eclipserc ] ; then
  . $HOME/.eclipserc
fi

# Set data dir if -data wasn't given.
if ! echo $@ | grep '\-data ' >/dev/null 2>&1 && [ -n "$USER_DIR" ]; then
  ECLIPSE_OPTS="$ECLIPSE_OPTS -data $USER_DIR"
fi

# Find our JVM.
# if [ ! -x "$JAVACMD" -a -r /usr/share/java-utils/java-functions ]; then
#   . /usr/share/java-utils/java-functions
#   set_javacmd
# fi

JAVACMD="/usr/lib/j2re1.5-sun/bin/java"

# Set JVM if -vm wasn't given.
if ! echo $@ | grep '\-vm ' >/dev/null 2>&1 && [ -n "$JAVACMD" ]; then
  ECLIPSE_OPTS="$ECLIPSE_OPTS -vm $JAVACMD"
fi

# Set JVM args if -vmargs wasn't given.  This needs to be the last option.
if ! echo $@ | grep '\-vmargs ' >/dev/null 2>&1 && [ -n "$VM_ARGS" ]; then
  VM_OPTS="-vmargs $VM_ARGS"
fi

# if [ -w $USER_DIR/.metadata/.config/platform.cfg ]; then
#   perl -p -i.bak -e 's|^site\.[0-9]*\.list\.[0-9]*=.*\n||g;' $USER_DIR/.metadata/.config/platform.cfg
# fi

/opt/eclipse/eclipse $ECLIPSE_OPTS $@ $VM_OPTS

Eclipse keeps running out of memory

Increase stack and heap sizes:

eclipse -vmargs -Xms40M -Xmx256M

You may also have to increase the space for permanent generation. See the Eclipse FAQ for more information.

Hovers/tooltips appear as black boxes without text

If you are using the Ambiance theme you may see empty black boxes when hovering over items that produce hovers or tooltips in Eclipse. Eclipse is using the system theme's tooltip background color and then writing black text on top of it. The problem presents when your system theme's tooltip background color is also black (black on black is hard to read). To fix:

  1. System->Preferences->Appearance

  2. Under the "Theme" tab click the "Customize" button.
  3. Under the "Colors" tab specify a new background color for tooltips (not black - in fact you may want to just go with white background and black text).
  4. You may need to restart eclipse for this change to take effect.

Another option to fix this problem is to use the custom gtk theme below which sets specific colors for gtk-tooltips.

"Failed to create a browser control to display diff." error

If you get a "Failed to create a browser control to display diff." error when running a Team > Commit then install the Ubuntu package "libswt-webkit-gtk3-jni" and "xulrunner-1.9.2". If these packages aren't available then check to see if an alternative xulrunner package is available.

If no xulrunner package is available for your version of Ubuntu then you can download an xulrunner runtime directly from mozilla (first check which xulrunner versions are compatible with your version of Eclipse), extract it to a directory and then add the line "-Dorg.eclipse.swt.browser.XULRunnerPath=<DIRECTORY>" to the end of your eclipse.ini file (as recommended here).

(see forum discussion).

Using a custom theme to make eclipse look better

Using an eclipse-specific gtk theme can make eclipse look better. 'apt-get fonts-liberation', save the following in ~/gtkrc-eclipse and run with 'GTK2_RC_FILES=~/gtkrc-eclipse eclipse':

style "eclin" {
GtkButton::default_border={1,1,1,1}
GtkButton::default_outside_border={1,1,1,1}
GtkButtonBox::child_min_width=0
GtkButtonBox::child_min_heigth=0
GtkButtonBox::child_internal_pad_x=0
GtkButtonBox::child_internal_pad_y=0
GtkMenu::vertical-padding=1
GtkMenuBar::internal_padding=1
GtkMenuItem::horizontal_padding=4
GtkToolbar::internal-padding=1
GtkToolbar::space-size=1
GtkOptionMenu::indicator_size=0
GtkOptionMenu::indicator_spacing=0
GtkPaned::handle_size=4
GtkRange::trough_border=0
GtkRange::stepper_spacing=0
GtkScale::value_spacing=0
GtkScrolledWindow::scrollbar_spacing=0
GtkExpander::expander_size=10
GtkExpander::expander_spacing=0
GtkTreeView::vertical-separator=0
GtkTreeView::horizontal-separator=0
GtkTreeView::expander-size=12
GtkTreeView::fixed-height-mode=TRUE
GtkWidget::focus_padding=0
font_name="Liberation Sans,Sans Regular 8"
}
class "GtkWidget" style "eclin"

style "eclin2" {
xthickness=1
ythickness=1
}

class "GtkButton" style "eclin2"
class "GtkToolbar" style "eclin2"
class "GtkPaned" style "eclin2"

style "gnome-color-chooser-tooltips"
{
  bg[NORMAL] = "#FFFFAF"
  fg[NORMAL] = "#000000"
}
widget "gtk-tooltip*" style "gnome-color-chooser-tooltips"

Notes

  • This guide has been tested using Ubuntu 6.06 (Dapper), Ubuntu 7.04 (Feisty), Ubuntu 7.10 (Gutsy), and Ubuntu 8.04 (Hardy).
  • http://www.easyeclipse.org/ could be a useful reference if you're having trouble configuring Eclipse.


CategoryProgramming

EclipseIDE (last edited 2012-10-10 15:13:47 by jack-list)