How to install java locally - no root - on linux, if possible?

Oracle offers JRE and JDK also as *.tar.gz for Linux. I usually had success just downloading such a package, untarring/unzipping it (tar -xzvf jdk-8u25.tar.gz) and then running it, using the absolute path.


It is quite easy...

Download the JDK as a tarball from Oracle (a simple google search will yield the link).

Unzip it somewhere in your $HOME (for instance, $HOME/jdk).

Set JAVA_HOME to the path of the root JDK install; then prepend $JAVA_HOME/bin to your PATH.

And off you go.


Here I have a particular setting insofar as I run three different major versions of the JDK: 6, 7, 8. For instance, here is my source file for setting the current shell to use Java 8:

$ cat ~/.jdk/8
export JAVA_HOME=/opt/sunjdk/1.8/current
export PATH="$JAVA_HOME/bin:$PATH"

And in /opt/sunjdk/1.8 (given that /opt/sunjdk is writable by my user hence I don't need to be root):

$ ls -l /opt/sunjdk/1.8/* -d
lrwxrwxrwx 1 fge fge  11 Oct 30 10:09 /opt/sunjdk/1.8/current -> jdk1.8.0_25
drwxr-xr-x 1 fge fge 274 Mar 18  2014 /opt/sunjdk/1.8/jdk1.8.0_05
drwxr-xr-x 1 fge fge 274 Sep 18 02:44 /opt/sunjdk/1.8/jdk1.8.0_25

(and yes, I was root to begin with so as to grant write permissions for /opt/sunjdk to "my" user; if you have no such liberty, just create another directory in your home)

Tags:

Linux

Java

Root