Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to install oracle jdk7 64bit on my computer.

And I found this How do I install Oracle Java JDK 7?

However I found that it use the update-alternative -install to install the jdk which is new to me.

I used to only extract the files and add the jdk location to the PATH environment variable before.

Now,it seems that I have to run the following commands more than once if I want to install other executables:

sudo update-alternatives --install "/usr/bin/xx" "xx" "/usr/lib/jvm/jdk1.7.0/bin/xx" 1

sudo chmod a+x /usr/bin/xx

Just like the post said:

N.B. remember - Java JDK has many more executables that you can similarly install as above. java, javac, javaws are probably the most frequently required.

So I think this is rather inflexible. Then I want to know what is the advantage to use the update-alternative to install jdk or something else?

share|improve this question
up vote 6 down vote accepted

The command sudo apt-get install openjdk-7-jdk should do the job. If there is a dependency problem run "sudo apt-get -f install" and rerun the earlier command.

share|improve this answer
The original post asked for Oracle JDK. – H2ONaCl Dec 31 '15 at 3:41
My answer has been accepted by the OP. I don't know what I can do now after more than two years ;) – Jay Dec 31 '15 at 5:09

There's an easier way to do it:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
share|improve this answer
This is super handy. I just signed up to up-vote this. Thanks. – Sam Rad Oct 21 '13 at 22:23

The command is for telling the system what the global java commands should execute. If you can live with just downloading a tar.gz file from Oracle and setting your PATH variable then just do that.

I usually just install the openjdk-7-jdk package to get what I need and do not worry any more about that.

share|improve this answer
I will do the android development. And it does not support the openjdk. – hguser Apr 11 '13 at 5:10
This it important information that you might consider adding to your question. – Thorbjørn Ravn Andersen Apr 11 '13 at 7:03

I'm noob. Hope somebody can correct me if i'm wrong.

You can install Oracle Java JDK apart from what already install in ubuntu which is OpenJDK. But you must aware that it's not safe and stable and oracle will always make update to its repository. You must update them manually to use the latest Oracle Java JDK, and also you must configure your browser to use Oracle Java JDK instead of OpenJDK which is more stable, safe, easy to install and update. If nothing important just stick with OpenJDK.

Hope it help. Thankyou.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.