Last active
December 19, 2015 06:59
-
-
Save camelcc/5915659 to your computer and use it in GitHub Desktop.
Install Oracle JDK on Ubuntu 12.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reference: [How do I install Oracle Java JDK 7?](http://askubuntu.com/questions/55848/how-do-i-install-oracle-java-jdk-7) | |
## 1. Install JDK | |
+ [Download](http://www.oracle.com/technetwork/java/javase/downloads/index.html) from Oracle page | |
+ Uncompress it | |
tar -xvf jdk-7u2-linux-x64.tar.gz | |
+ Move the JDK 7 directory to /usr/lib | |
sudo mkdir -p /usr/lib/jvm | |
sudo mv ./jdk.1.7.0_02 /usr/lib/jvm/jdk1.7.0 | |
## Config | |
+ Now run | |
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1 | |
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1 | |
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1 | |
+ Correct the file ownership and the permissions of the executables: | |
sudo chmod a+x /usr/bin/java | |
sudo chmod a+x /usr/bin/javac | |
sudo chmod a+x /usr/bin/javaws | |
sudo chown -R root:root /usr/lib/jvm/jdk1.7.0 | |
+ Also you can use alternative command line to config | |
sudo update-alternatives --config java | |
sudo update-alternatives --config javac | |
sudo update-alternatives --config javaws | |
## Check | |
+ Run | |
java -version | |
It should give output of java version "1.7.0". | |
## Web plugins | |
+ Enable mozilla firefox plugin: | |
ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/ | |
+ update the apparmor profile for firefox (or other browsers) in /etc/apparmor.d/abstractions/ubuntu-browsers.d/java | |
# Replace the two lines: | |
# /usr/lib/jvm/java-*-sun-1.*/jre/bin/java{,_vm} cx -> browser_java, | |
# /usr/lib/jvm/java-*-sun-1.*/jre/lib/*/libnp*.so cx -> browser_java, | |
# with those (or adapt to your new jdk folder name) | |
/usr/lib/jvm/jdk*/jre/bin/java{,_vm} cx -> browser_java, | |
/usr/lib/jvm/jdk*/jre/lib/*/libnp*.so cx -> browser_java, | |
+ Then restart apparmor: | |
sudo /etc/init.d/apparmor restart | |
+ Verify | |
[http://java.com/en/download/installed.jsp](http://java.com/en/download/installed.jsp) | |
## Chrome plugin (need to `mkdir` the plguins folder) | |
ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/amd64/libnpjp2.so /opt/google/chrome/plguins/ | |
## Uninstall JDK | |
+ Remove the link | |
sudo update-alternatives --remove "java" "/usr/lib/jvm/jdk[version]/bin/java" | |
sudo update-alternatives --remove "javac" "/usr/lib/jvm/jdk[version]/bin/java" | |
sudo update-alternatives --remove "javaws" "/usr/lib/jvm/jdk[version]/bin/javaws" | |
+ Remove file | |
sudo mv /usr/lib/jvm/jdk[version] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment