![]() |
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 | |
|
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). |
|
|
|
|
|
|
#4 | |
|
5 Cups of Ubuntu
![]() Join Date: Nov 2007
Location: Brooklyn, NY
Beans: 27
Ubuntu 7.10 Gutsy Gibbon
|
Re: Installing and setting up Eclipse with Sun's Java
Wow searching through old posts really works. This is exactly what I was trying to do. Thanks!
Quote:
Thanks again. |
|
|
|
|
|
|
#5 |
|
Fresh Brewed Ubuntu
![]() |
Re: Installing and setting up Eclipse with Sun's Java
Xms sets the minimum heap size, Xmx sets the maximum heap size.
__________________
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). |
|
|
|
|
|
#6 |
|
Quad Shot of Ubuntu
![]() |
Re: Installing and setting up Eclipse with Sun's Java
Hopefully no one will bash me for bumping an old thread.
I downloaded eclipse from eclipse.org and simply unpacked and ran it. It was painfully slow, so I found this thread and installed SUN's Java, but I can't edit the /etc/eclipse/java_home file, since there is no such file. If I go to Window -> Preferences -> Java -> Installed JREs there's only one in the list and it is /usr/lib/jvm/java-6-sun-1.6.0.06 . Does that mean Eclipse is using SUN's Java? If not, what can I do to make it use it? Thanks. |
|
|
|
|
|
#7 | |
|
Fresh Brewed Ubuntu
![]() |
Re: Installing and setting up Eclipse with Sun's Java
Quote:
Code:
$ /usr/bin/eclipse searching for compatible vm... testing /usr/lib/jvm/java-gcj...not found testing /usr/lib/kaffe/pthreads...not found testing /usr/lib/jvm/java-6-sun...found
__________________
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 | |
|
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 |
|
|
|
|
|
|
#9 |
|
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... |
|
|
|
|
|
#10 | |
|
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). |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|