It’s a shame IBM didn’t buy Sun, since the guys at Oracle are just not much fun. Case in point, you can’t just apt-get
the Oracle JDK/JRE. No, that would be too easy and Oracle does not want you to be their friend. Rather, they’d prefer you register with their site, accept their legal terms, and download/install everything manually because this is the right way to discourage the use of Java.
Here’s how:
- Download the JRE/JDK files (the .bin files, not .rpm files) from Oracle’s site
- Sign up, become their friend, accept their licenses.
Follow the below commands (note: change version to match your download)
cd /usr/lib/jvm/ sudo cp ~/Downloads/*.bin . sudo chmod a+x *.bin sudo unzip *.bin sudo ./jdk-6u30-linux-x64.bin sudo ./jre-6u30-linux-x64.bin sudo update-alternatives –install “/usr/bin/java” “java” “/usr/lib/jvm/jre1.6.0_30/bin/java” 1 sudo update-alternatives –set java /usr/lib/jvm/jre1.6.0_30/bin/java 1 sudo update-alternatives –install “/usr/lib/jvm” “javac” “/usr/lib/jvm/jdk1.6.0_30/bin/javac” 1 sudo update-alternatives –set java /usr/lib/jvm/jre1.6.0_30/bin/java
Confirm that the new JRE/JDK are the default versions
java -version javac -version
Cleanup
. /etc/profile sudo rm *.bin
Sure, you may ask what is wrong with OpenJDK, which does have a nice auto installer? Simply, for many enterprise Java bits, it just does not fly, and if Oracle had their way, it would not exist. Again, too bad Oracle is working to kill Java.
Update: 3 Feb 2015
It’s far easier now due to the WebUpd8Team
:
sudo apt-get purge openjdk*
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer