Installing Sun's JDK 6 On Ubuntu

Guest Author

I installed the latest release of Ubuntu - 7.04 on my home computer. I am quite happy with it, however I am a bit disappointed that Sun's Java is still not available by default. The default Java is GCJ, which unfortunately is not 100% Sun java compatible. So how to exchange GCJ for Sun Java?

  1. You can find out where is java installed by running "which java".
  2. The version can be determined by running "java -version".
  3. To install Sun's JDK 6, switch to root and run "apt-get install sun-java6-jdk". You can also run sudo if you don't want to switch to root: "sudo apt-get install sun-java6-jdk".
  4. Proceed with the installation and confirm the license terms.
  5. Now you should get the correct message when running "java -version":

java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

I hope that Sun's Java will become default in Ubuntu soon. Not sure if there are any reasons why it should not be the default, now that it's fully open source. The experience will be much better for beginners who may run into problems with GCJ because it doesn't support all Java applications at this moment.

Join the discussion

Comments ( 4 )
  • Paris Apostolopoulos Tuesday, June 5, 2007
    For sure..the joke with GCJ, Blackdown JVM has to stop. At the time being Sun's implementation is far better comparing to all the alternatives and there are lots of linux users who do not know the difference or proper java..and something close to java.
    I had 2 cases at work where one developer, linux addict was arguing that a java based tool that he was using was very very bad at his new Fedora installation. I explained him why swing was really bad, we changed the JRE to Sun's one. The other day he said ' you are right, it works fine now!'
    The other case today a developer using Ubuntu, by default the jre is 1.4 blackdown. Even though he used the package manager to install Sun's implementation still the path was not right.The BD jvm was in the path. I had to manually overide the sim link in the /usr/bin/ to point to the proper JRE!
    Anyway I hope better days will come for Sun's Java in the linux world.We are getting lots of bad..words from non java people in linux and some times it's not 'proper' java's fault!
  • Lucian Pintilie Tuesday, June 5, 2007
    Of course, there's the alternate method: don't use the repository of your Linux distribution, go to Sun's website, download the appropriate installer and take care of it yourself. This way you can get the latest version, which may correct some bugs. See http://java.sun.com/javase/6/webnotes/ReleaseNotes.html#160_01
  • David Herron Tuesday, June 5, 2007
    Um, what has been open sourced is the project which will eventually become Java 7. The OpenJDK project is not "completely open sourced" but somewhere around 95% open sourced. There are encumbrances etc which we're working on clearing. The binaries such as the one you installed on Ubuntu are made available through the JDK-Distros Project which are repackaged binary bundles distributed under the DLJ license. That's not an open source license but a very liberal binary license. The advantage of using the DLJ is it allows the distribution maker to more tightly couple the JDK with their platform, so that their packaging system knows that a package provides 'Java', so that they more easily can package and distribute Java applications taking advantage of the packaging system to correctly determine the dependencies leading to installing 'Java' etc. For Sun's Java to become default in any of the OSS distributions such as Ubuntu or Debian, we have to complete the encumbrance clearing exercise. Until we do the distributions are unable to bundle Sun's Java because the existing bundle is not open source.
  • John Stevenson Tuesday, June 19, 2007

    If you have more than one package that provides Java you will need to configure the alternatives:

    sudo update-alternatives --config java

    A text menu displays showing you which package is currently used for Java. You can select a different package to use as the default Java.

    If there are no packages that provide the version of Java you like, you can install an alternative from a manual java install using the command:

    sudo update-alternatives --install java /opt/jdk_1.6.0_u9 600

    This command assumes you have downloaded the install from Sun (or wherever) and installed it into /opt

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.