Terry : Install Java Manually on Linux

Install JDK Manually on Linux

Download JDK 6.0 and 7.0 from Oracle Technology Network

For example jdk 1.6.0_35, extract it to /opt/java/jdk1.6.0_35

Tell the system that there's a new Java version available by using update-alternatives command

update-alternatives --install <link> <name> <path> <priority> [--slave <link> <name> <path>] ...

add a group of alternatives to the system.

Icon

link is the generic name for the master link, name is the name of its symlink in the alternatives directory, and path is the alternative being introduced for the master link.
The arguments after --slave are the generic name, symlink name in the alternatives directory and the alternative path for a slave link. Zero or more --slave options, each followed by three arguments, may be specified.

Install JDK

example, install JDK 1.6.0_35:

update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_35/bin/java" 1
update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_35/jre/bin/java" 2

Same as:

update-alternatives --install /usr/bin/java java /opt/jdk1.6.0_35/bin/java 1
update-alternatives --install "/usr/bin/java java /opt/jdk1.6.0_35/jre/bin/java 2

 NOTE: " " is optional.

Icon

If updating from a previous version that was removed manually, execute the above command twice, because you'll get an error message the first time.

Set the new JRE as the default:

sudo update-alternatives --set java /opt/java/jdk1.6.0_35/bin/java

or

sudo update-alternatives --config java
root@ubuntu:/opt# update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
* 1 /opt/jdk1.6.0_35/bin/java 1 manual mode
2 /opt/jdk1.6.0_35/jre/bin/java 2 manual mode
3 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
Press enter to keep the current choice[*], or type selection number:

Choose and run java -version to confirm.

Remove old JRE/JDK links (to upgrade)

For example, upgrade from JDK 1.6.0_35 to 1.6.0_37:

root@ubuntu:/opt# update-alternatives --remove "java" "/opt/jdk1.6.0_35/bin/java"
root@ubuntu:/opt# update-alternatives --remove "java" "/opt/jdk1.6.0_35/jre/bin/java"
update-alternatives: removing manually selected alternative - switching java to auto mode
update-alternatives: using /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in auto mode.

Install new JRE/JDK

For example:

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_37/bin/java" 1
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_37/jre/bin/java" 2

For internals, look into

  • alternatives directory containing symbolic links - /etc/alternatives
  • administration directory containing state information - /var/lib/dpkg/alternatives

Browser plugins (Firefox and Chrome)

Manual Plugin Install on Linux

Google Chrome (Ubuntu)

/opt/google/chrome

libpdf.so (built-in PDF viewer)

Try Creating symbolic link to libnpjp2.so

ln -s /opt/jdk1.6.0_37/jre/lib/amd64/libnpjp2.so /opt/google/chrome/libnpjp2.so

 NOTE: The above does NOT work!

 Create the symbolic link in Firefox plugins folder (works system wide, for all users)

ln -s /opt/jdk1.6.0_37/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins/libnpjp2.so

OR

ln -s /opt/jdk1.6.0_37/jre/lib/amd64/libnpjp2.so /usr/lib/firefox/plugins/libnpjp2.so

Per User

create the symbolic link in ~/.mozilla/plugins or Firefox profile’s plugins folder in ~/.mozilla/firefox

For example:

ln -s /opt/jdk1.6.0_37/jre/lib/amd64/libnpjp2.so /home/terry/.mozilla/plugins/libnpjp2.so

Firefox profile /home/terry/.mozilla/firefox/7n8pq28j.default/plugins

ln -s /opt/jdk1.6.0_37/jre/lib/amd64/libnpjp2.so /home/terry/.mozilla/firefox/7n8pq28j.default/plugins/libnpjp2.so

NOTE: For my major Linux workstation, symbolic link is in ~/.mozilla/plugins

GitHub project - oab-java.sh script, build .deb packages and set up a local repository, install from local repository

Reference

Build Debian/Ubuntu packages from OTN binaries

https://github.com/rraptorr/oracle-java7/blob/master/debian/JB-plugin.prerm.in

https://github.com/rraptorr/oracle-java7/blob/master/debian/JB-plugin.postinst.in