Problem: On Ubuntu, Eclipse freezes randomly
Analysis: Eclipse is always loaded using GIJ despite having sun-java-6 set up
Solution: Add sun-java-6 JVM path to /etc/eclipse/java_home
- Open the terminal and type this:
# sudo gedit /etc/eclipse/java_home
- Add the line “/usr/lib/jvm/java-6-sun” on top of the list
- Save and Exit
- Restart Eclipse
Filed under: Eclipse, Information Technology, Ubuntu | 10 Comments



You can do something like this actually:
# sudo update-java-alternatives -s java-1.6.0-sun
It will enforce other Java applications to use java1.6 instead.
Oh, and don’t forget to set JAVA_HOME and JDK_HOME variables also.
@Andry:
Well actually I did that (update-alternatives) and I was surprised that to find that Eclipse is still using GCJ. I Googled that and found out that I need to manually change that file I mentioned.
Maybe my mistake was not setting the JAVA_HOME or JDK_HOME variables correctly. Thanks for the response.
Oh thank goodness, that finally fixed it. I tried #sudo update-java-alternatives … and it was still running the 1.4.2 jvm in eclipse (Mylyn requires version 5)…
Thanks for the tip,
Aaron
thnx a ton for the info, it solved my problem!!
Thank you for this
It helped me getting around a problem where the SubclipsePlugin was unable to connect to repositories withi https using webdav.
After installing Java 6 (on Ubuntu)
sudo apt-get install sun-java6-jre
and making your change it worked.
I solved this problem by installing jdk from Sun’s website. Then I make symbolic link from java, jar and javac in my jdk’s bin directory to /usr/bin.
This way:
$ sudo rm /usr/bin/java
$ sudo rm /usr/bin/jar
$ sudo ln -s /opt/jdk1.6/bin/java /usr/bin/java
$ sudo ln -s /opt/jdk1.6/bin/javac /usr/bin/javac
$ sudo ln -s /opt/jdk1.6/bin/jar /usr/bin/jar
@amrishodiq:
That could be an alternative solution.
But I prefer installing applications from the official repositories whenever possible because it makes it easy to remove/upgrade it later on.
I was having performance issues with Eclipse. I tried using “update-alternatives”, but Eclipse was still being called with a non-sun java. This solved the problem–thanks!
Wow! thank you. I was having an issue getting pydev working properly with eclipse on Ubuntu 7.10 AMD64 and I noticed I was always using the gcj java, even when I did the “alternatives” method mentioned. This not only allowed me to use java-6-sun, but pydev now works fine for me.
Thanks!
Thanks for instructions on the /etc/eclipse/java_home file. It worked great for me in Ubuntu 8.10 and now I have Eclipse running with java-6-sun.