How to install Oracle Java 6 JDK on Ubuntu 12.10

  • download the .bin JDK from here;
  • run the following commands (if you have a 32-bit machine replace x64 with i586):
chmod +x jdk-6u43-linux-x64.bin
./jdk-6u43-linux-x64.bin
sudo chown root. -R jdk1.6.0_43/
sudo mv jdk1.6.0_43/ /usr/lib/jvm/

sudo update-alternatives --install "/usr/bin/java" "java" 
"/usr/lib/jvm/jdk1.6.0_43/bin/java" 1

sudo update-alternatives --install "/usr/bin/javac" "javac" 
"/usr/lib/jvm/jdk1.6.0_43/bin/javac" 1

sudo update-alternatives --install "/usr/bin/javaws" "javaws" 
"/usr/lib/jvm/jdk1.6.0_43/bin/javaws" 1

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws

 

If you have a JAVA_HOME variable set, then you need to update that with the new path (/usr/lib/jvm/jdk1.6.0_43).

 

Advertisements

15 thoughts on “How to install Oracle Java 6 JDK on Ubuntu 12.10

  1. Thank you. This is the right way of doing this instead of all the silly “check out my repository” methods everyone else wants to use. Unless Oracle sets up an ubuntu repo, i much prefer this way.

  2. can you explain this:

    sudo update-alternatives –install “/usr/bin/java” “java”
    “/usr/lib/jvm/jdk1.6.0_33/bin/java” 1

    sudo update-alternatives –install “/usr/bin/javac” “javac”
    “/usr/lib/jvm/jdk1.6.0_33/bin/javac” 1

    sudo update-alternatives –install “/usr/bin/javaws” “javaws”
    “/usr/lib/jvm/jdk1.6.0_33/bin/javaws” 1

    Why do I need to do that?
    New to the Linux world :).

    1. Those are needed for you to be able to switch system-wide between all the different JVMs you have installed.

      For each of the three commands (java, javac and javaws) it installs (adds) a new alternative to the system. The first parameter “/usr/bin/java” is the symlink in your system that points to the currently active alternative. The seconds parameter “java” is the name that update alternatives uses to keep track of the alternatives, the fourth parameter is the new path to the alternative you want to add.

      You can find more information about the update-alternatives command at this page:
      http://linux.die.net/man/8/update-alternatives

  3. So if I understand correctly, if you have jdk 6 and 7 on your system. You need to use that if you want to switch from 6 to 7 and vice versa?

    1. The JAVA_HOME environment variable is a required configuration item for many programs and compilers that make use of the JDK, like Tomcat and other Java EE app servers, but it is not mandatory, it is just a convention.

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