Ubuntu – Install JDK in Ubuntu

javajdkoracle

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

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

It uses 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.

I think this is rather inflexible. So I want to know what the advantage of using update-alternative to install jdk over other methods is.

Best Answer

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.