![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Fresh Brewed Ubuntu
![]() |
Installing and setting up Eclipse with Sun's Java
This howto explains how to install Eclipse and Sun's Java on Ubuntu 8.04 (Hardy Heron), and how to make Eclipse actually use Sun's Java solving the "Eclipse is horribly slow" problem caused by bug 45347.
The entire install process consists simply of installing the following 2 meta packages: eclipse and sun-java6-jdk. Note, you can optionally choose to use the openjdk-6-jdk package instead of Sun's package, which is the open-source jdk for ubuntu. Code:
sudo apt-get install eclipse sun-java6-jdk Code:
sudo update-java-alternatives -s java-6-sun Code:
sudo -b gedit /etc/jvm Code:
/usr/lib/jvm/java-6-sun Code:
sudo -b gedit /etc/eclipse/java_home Code:
/usr/lib/jvm/java-6-sun 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/lib/eclipse/eclipse.ini 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 Edit 6: Updated eclipse ini path for feisty users (thanks biTaZ and ksenos)
__________________
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). Last edited by hod139; September 9th, 2008 at 10:27 PM.. Reason: Updated from dapper to hardy |
|
|
|
|
|
#2 |
|
First Cup of Ubuntu
![]() Join Date: Jan 2006
Beans: 3
|
Re: Installing and setting up Eclipse with Sun's Java
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 |
|
|
|
|
|
#3 | |
|
First Cup of Ubuntu
![]() Join Date: Oct 2005
Beans: 7
|
Re: Installing and setting up Eclipse with Sun's Java
Ok, I wanted to post this, but I will just complete your post:
Quote:
Code:
.....
# If the user has specified a custom JAVA, we check it for validity.
# JAVA defines the virtual machine that Eclipse will use to launch itself.
if [ -n "${JAVA_HOME}" ]; then
echo "using specified vm: ${JAVA_HOME}"
.....
# If the user has not set JAVA_HOME, cycle through our list of compatible VM's
# and pick the first one that exists.
if [ -z "${JAVA_HOME}" -a ! -n "${JAVACMD}" ]; then
echo "searching for compatible vm..."
javahomelist=`cat /etc/eclipse/java_home | grep -v '^#' | grep -v '^$' | while read line ; do echo -n $line ; echo -n ":" ; done`
OFS="$IFS"
IFS=":"
for JAVA_HOME in $javahomelist ; do
echo -n " testing ${JAVA_HOME}..."
....
Ok, so what we see here is this: Eclipse searches for the Environment variable named JAVA_HOME which you should have set.If it does not find it, it will go through the vm-s in its list /etc/eclipse/java_home. So, we try to see if the script works: Code:
~$ export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun $ eclipse using specified vm: /usr/lib/jvm/java-1.5.0-sun ........ For a permanent setting add it to ~/.bashrc or ~/.bash_profile or whatever you use for your profile (I think .bashrc is default) PS: At configuring the update alternatives.You can just do the old way and simbolic link applications in /usr/bin to the correct applications.Like : Code:
ln -sf /usr/lib/jvm/java-1.5.0-sun/bin/java java And I also have a javah in my /usr/bin maybe you should list that too in your list. Greets, Matei |
|
|
|
|
|
|
#4 | |
|
Fresh Brewed Ubuntu
![]() |
Re: Installing and setting up Eclipse with Sun's Java
Quote:
Code:
/usr/share/eclipse/eclipse.ini Code:
-vmargs -Xms40m -Xmx256m
__________________
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). |
|
|
|
|
|
|
#5 |
|
A Carafe of Ubuntu
![]() Join Date: Nov 2005
My beans are hidden!
Ubuntu 6.06
|
Re: Installing and setting up Eclipse with Sun's Java
Just wanted to confirm this worked great in xubuntu dapper. Eclipse opened much faster than ever, dunno if xfce or the Xms Xmx settings were the kickers, but I'm happy!
Thanks
__________________
"Life is the fire in which we burn." 3 Links everyone should have bookmarked: Linux Doc Project Freshmeat - Package Heaven Eric S. Raymond's site |
|
|
|
|
|
#6 |
|
5 Cups of Ubuntu
![]() Join Date: Apr 2006
Beans: 21
|
Re: Installing and setting up Eclipse with Sun's Java
I have an example of a script that sets JAVA_HOME from the update-alternatives controlled path at http://www.ubuntuforums.org/showthre...84#post1296484
- possibly putting this script in your .bashrc might be more reliable than manually setting JAVA_HOME? Be warned, I haven't really played around with it much. Also, generally it's better to call update-java-alternatives than update-alternatives - it calls update-alternatives for each of the java programs, not just java and javah. When I've had a chance to test this properly, I might write it up as a howto... |
|
|
|
|
|
#7 | |
|
Fresh Brewed Ubuntu
![]() |
Re: Installing and setting up Eclipse with Sun's Java
Quote:
Code:
/usr/share/java-common/jvm-find.sh
__________________
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). |
|
|
|
|
|
|
#8 |
|
5 Cups of Ubuntu
![]() Join Date: Apr 2006
Beans: 21
|
Re: Installing and setting up Eclipse with Sun's Java
fair enough - my only problem with that script is that it falls back to /etc/jvm, which is a parallel and alternative way of selecting JVMs to the update-alternatives way.
If people reliable edit /etc/jvm at the same time as running update-alternatives, this will work fine. I just wish these things could be set in one place! /etc/jvm is actually slightly nicer in some ways, as it allows a user to override the system-wide default - but it will only work with ubuntu or debian packaged apps; command-line calls to java, or manually installed apps, will typically look for JAVA_HOME, or rely on the "java" command in the path. |
|
|
|
|
|
#9 |
|
Fresh Brewed Ubuntu
![]() |
Re: Installing and setting up Eclipse with Sun's Java
__________________
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). |
|
|
|
|
|
#10 |
|
First Cup of Ubuntu
![]() Join Date: Dec 2005
Beans: 4
|
Re: Installing and setting up Eclipse with Sun's Java
Very good howto! I have been waiting for this for a while.
It should be one big bug report for update-java-alternatives. |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|