Manual installation of JDK 1.7 on UBUNTU 12.04 LTS

OpenJKD6GeneologyI’ve messed up my old Linux Mint distribution installation, so I decided for a little change. I installed long term stable version of Ubuntu 12.04. I found out, that for a Java developer, there is a little problem, only a little problem 😉

OpenJDK in Ubuntu

Because of licencing issues and other reasons Ubuntu decided to choose open source version of JDK7. OpenJDK was basically originally based on Sun (resp. Oracle) JDK7 b10. More on genealogy of OpenJDK you can find on Mr. Joseph D. Darcy’s Oracle web blog here. Other additional information provided Mr. Henrik Stahl here. Further discussion about this topic, you can find on Stack Overflow. Some application are not very compatible with OpenJDK.

Presumptions and Warnings

  • This tutorial is working with fresh installation of Ubuntu 12.04 64bit version. I do not know, and neither test if it works on something else.
  • You already downloaded or will download *.tar.gz package with JDK7 from Oracle site.
  • I assume basic knowledge of Terminal, and basic knowledge of  apt-get command.
  • Be carefully with the sudo  command in console.
  • Whatever you can read here is my experience, and absolutely not objective facts. There can be other, and better ways to finish this task. If so, you can start discuss you experience under the article.

How to install Oracle JDK

  1. The first step is to get rid of OpenJDK with this command:
    sudo apt-get purge openjdk*
  2. Copy previous uncopressed downloaded version of JDK by this command:

    The option -p in mkdir command will return no error if existing, and it will make all parent directories as needed.
  3. Now you should create simlinks, but we will use alternative function for this task:

    For further study you can look on update-alternatives command. The update-alternatives has –configure option as well, here you can choose the version of JDK you want use. I will not explain details, because it is out of scope of my tutorial. By studying update-alternative command, it should be kinda clear what you have to do.
  4. At the end you should change file permition by  chmod  command and owner of jdk1.7.45 directory by  chown  command:
  5. Test the version of java: java -version . My output is:

This was my way of cope with installing JDK 1.7 on Ubuntu 12.04. It worked for me, hopefully it will for you as well. If not, please provide details, and the working workflow below article in discussion section.


  • The discussion group in here and here.


Please tell what you think