Back to Top

Friday, June 06, 2008

Using Eclipse with OpenJDK 6 on Ubuntu

Update: There seems to be a simpler way to do this. Take a look at the second comment.

Java 1.6 (also known as Java 6) is now open-source so I installed it on Ubuntu and tried to run Eclipse with it. Unfortunately it said that no compatible java vm was found while searching /usr/lib/j2sdk1.4-sun/bin/java. So I dropped to the command line and tried to run it from there and found out several things:

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...not found
  testing /usr/lib/jvm/java-1.5.0-sun...not found
  testing /usr/lib/j2se/1.5...not found
  testing /usr/lib/j2se/1.4...not found
  testing /usr/lib/j2sdk1.5-ibm...not found
  testing /usr/lib/j2sdk1.4-ibm...not found
  testing /usr/lib/j2sdk1.6-sun...not found
  testing /usr/lib/j2sdk1.5-sun...not found
  testing /usr/lib/j2sdk1.4-sun...not found
Could not create /usr/local/lib/eclipse/.eclipseextension. Please run as root:
    touch /usr/local/lib/eclipse/.eclipseextension
    chmod 2775 /usr/local/lib/eclipse/.eclipseextension
    chown root:staff /usr/local/lib/eclipse/.eclipseextension

First, it was searching in more locations than the dialog box said. Second there seems to be some additional problems related to extensions, fortunately the error message also contained the advice on how to fix it. So first of all I created a symlink to where eclipse was expecting to find java:

sudo mkdir -p /usr/lib/j2sdk1.6-sun/bin
sudo ln -s /usr/bin/java /usr/lib/j2sdk1.6-sun/bin/java

Second, I followed the advice from the error message:

sudo su
touch /usr/local/lib/eclipse/.eclipseextension
chmod 2775 /usr/local/lib/eclipse/.eclipseextension
chown root:staff /usr/local/lib/eclipse/.eclipseextension
exit

And now Eclipse seems to run fine.

6 comments:

  1. Same problem here. Solution worked great, thanks!

    ReplyDelete
  2. An easier way is to edit the /etc/eclipse/java_home file and place this at the top of the list:

    /usr/lib/jvm/java-6-openjdk

    ReplyDelete
  3. Well, I'm by no means an Eclipse (or Java) expert, so that probably works (and look easier). Thanks.

    ReplyDelete
  4. You can also do:

    update-java-alternatives -s java-6-openjdk

    ReplyDelete
  5. Anonymous10:49 PM

    To mention one of possible problems when eclipse doesn't find JVM in script:
    /usr/bin/eclipse
    ..
    JAVACMD="/usr/lib/j2re1.5-sun/bin/java"
    in my case i changed it to:
    JAVACMD="/usr/lib/jvm/ia32-java-6-sun-1.6.0.07/jre/bin/java"
    or use jvm that is installed in system.

    ReplyDelete
  6. Anonymous7:40 PM

    Thank you very much.

    ReplyDelete