Thursday, May 17, 2007

Installing and setting up Eclipse with Sun's Java - Ubuntu Forums

Installing and setting up Eclipse with Sun's Java - Ubuntu Forums

This howto explains how to install Eclipse and Sun's Java on Ubuntu 6.06 LTS (Dapper Drake), and how to make Eclipse actually use Sun's Java solving the "Eclipse is horribly slow" problem. This tutorial should work fine for more recent versions of Ubuntu.

The entire install process consists of installing the following 2 meta packages: eclipse sun-java6-jdk (Java 6 is available in the backports repository. If you do not wish to enable this repository you will be forced to use instead sun-java5-jdk)
Code:
sudo apt-get install eclipse sun-java6-jdk
This will install the required packages, however, Eclipse will run very slowly since it will be using GNU's java, not Sun's. We now need to make Sun's java the default. First (for those using java 5, replace java-6-sun with java-1.5.0-sun),
Code:
 sudo update-java-alternatives -s java-6-sun
Next, edit the JVM configuration file
Code:
sudo -b gedit /etc/jvm
and add the following to the top of the file
Code:
/usr/lib/jvm/java-6-sun
There is a bug right now were Eclipse ignores Ubuntu's java-common settings and uses its own (bug 45347). To work around the bug, you need to edit Eclipse's java_home file
Code:
sudo -b gedit /etc/eclipse/java_home
and add
Code:
/usr/lib/jvm/java-6-sun
to the top of the file.

Lastly, if you have lots of memory you may want to increase the heap size (warning: If you make the heap size too large then parts of eclipse will continuously swap in and out.).
The settings can be altered by editing the eclipse.ini file.
Code:
sudo -b gedit /usr/share/eclipse/eclipse.ini
the argument Xms refers to the minimum heap size and Xmx refers to the maximum heap size.
For more on tuning the Eclipse JVM heap size, you can refer to this IBM article.

That's it.

Edit 1: Make mention of the /usr/share/eclipse/eclipse.ini file for setting heap size (thanks belial6)
Edit 2: Added javah to update-alternatives list (thanks anarhistu)
Edit 3: Clarified discussion on Eclipse bug (thanks anarhistu for pointing out this was unclear)
Edit 4: Use update-java-alternatives instead of update-alternatives. (thanks korny)
Edit 5: Updated java to version 6
__________________
When I invented the Web, I didn't have to ask anyone's permission.
~Tim Berners-Lee on Net Neutrality
-------------------------------------
Visit the Ubuntu Programming IRC-channel at #ubuntu-programming (chat.freenode.net).


For me Eclipse was very slow because the default heap size was relatively small. So I increased the heap.

Since I have 1 gig of ram I put max heap to 256 MB and default to 100MB.

Here is what I changed in /usr/bin/eclipse script (that's where my eclipse startup script is):
Before there weren't any vm arguments
VMARGS=""

Changed it to this
VMARGS="-Xms100m -Xmx256m"


And now eclipse is running much faster. Before I had problems working with just 5 editor windows open. Now I can easily open 20 of them


No comments:

如何发掘出更多退休的钱?

如何发掘出更多退休的钱? http://bbs.wenxuecity.com/bbs/tzlc/1328415.html 按照常规的说法,退休的收入必须得有退休前的80%,或者是4% withdrawal rule,而且每年还得要加2-3%对付通胀,这是一个很大...