installing latest oracle jdk in old ubuntu


add the repository

$ sudo add-apt-repository ppa:webupd8team/java

when

sudo: add-apt-repository: command not found

then

$ sudo apt-get install python-software-properties

update

$ sudo apt-get update

install

$ sudo apt-get install oracle-java7-installer
$ sudo apt-get install oracle-java8-installer

switch

$ ls -1F /usr/lib/jvm/
java-7-oracle/
java-8-oracle/

$ update-java-alternatives -l
java-7-oracle ...
java-8-oracle ...

$ sudo update-java-alternatives -s java-7-oracle
$ java -version
java version "1.7.x_yy"
...

$ sudo update-java-alternatives -s java-8-oracle
$ java -version
java version "1.8.x_yy"
...
$

switch along java_home

$ cat java7
#!/bin/sh
alternative=java-7-oracle
sudo update-java-alternatives -s $alternative
export JAVA_HOME=/usr/lib/jvm/$alternative

$ cat java8
#!/bin/sh
alternative=java-7-oracle
sudo update-java-alternatives -s $alternative
export JAVA_HOME=/usr/lib/jvm/$alternative

$ . java7;javac -version;echo $JAVA_HOME
javac 1.7.x_yy
/usr/lib/jvm/java-7-oracle

$ . java8;javac -version;echo $JAVA_HOME
javac 1.8.x_yy
/usr/lib/jvm/java-8-oracle

if you want to remove the repository

$ sudo add-apt-repository ppa:webupd8team/java --remove

interesting…

export JAVA_HOME=$(dirname $(dirname $(readlink -e /usr/bin/javac)))
export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
Advertisements

2 comments

  1. Pingback: ucloudbiz – project server add. | gasaepiri
  2. Pingback: JAVA_HOME Environment Variable | jinahya

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s