Skip to content

Use Sun Java for Eclipse on Ubuntu

June 15, 2007

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

  1. Open the terminal and type this:

    # sudo gedit /etc/eclipse/java_home

  2. Add the line “/usr/lib/jvm/java-6-sun” on top of the list
  3. Save and Exit
  4. Restart Eclipse
10 Comments
  1. 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.

  2. @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.

  3. 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

  4. thnx a ton for the info, it solved my problem!!

  5. 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.

  6. amrishodiq permalink

    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

  7. @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.

  8. Ryan permalink

    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!

  9. Stu permalink

    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!

  10. Scott D permalink

    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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: