0

I downloaded the java latest version from http://www.oracle.com/technetwork/java/javase/downloads/index.html this site for Linux 64-bit. I installed default-jdk, now when i run $java -version this command i got

java version "1.7.0_111"
OpenJDK Runtime Environment (IcedTea 2.6.7) (7u111-2.6.7-0ubuntu0.14.04.3)
OpenJDK 64-Bit Server VM (build 24.111-b01, mixed mode)

Now i would like to configure java what i have downloaded. Is it possible to configure manually to the latest version?

Thanks & Regards

Jaccs
  • 1,052
  • 3
  • 12
  • 33

3 Answers3

0

You can edit file /etc/profile with sudo and add following lines at the end:

export JAVA_HOME="/path/to/java/folder"
export PATH=$JAVA_HOME/bin:$PATH

My example:

export JAVA_HOME="/usr/lib/jvm/java-8-oracle"
export PATH=$JAVA_HOME/bin:$PATH

Then save the file, and enter source /etc/profile in the terminal. Then relaunch the terminal and check the version again.

Alexiy
  • 1,966
  • 16
  • 18
  • I edited that /etc/profile and i added export JAVA_HOME="/usr/lib/jvm/jdk1.8.0_101" export PATH=$JAVA_HOME/bin:$PATH These two line at the end of file. Still i can't able to get latest version config when running java -version. – Jaccs Sep 01 '16 at 08:53
0

Kiran , you will have to set the right alternatives once you install the Oracle JDK. A very detailed explanation of it is available here. The alternatives can be listed as

sudo update-alternatives --config java 

you can then choose the JDK of choice

The Path that you have right now points to the Open JDK. You may have to edit your .bash files and add the path to the Oracle JDK binaries as well

Ramachandran.A.G
  • 4,788
  • 1
  • 12
  • 24
  • where can i found .bash and Oracle JDK binaries? – Jaccs Sep 01 '16 at 08:49
  • you may have to execute whereis java , the default i believe is in /usr/lib/jvm/... (refer this :https://stackoverflow.com/questions/16931327/where-is-the-java-sdk-folder-in-my-computer-ubuntu-12-04) – Ramachandran.A.G Sep 01 '16 at 09:17
0
  1. Download jdk from oracle https://www.oracle.com/in/java/technologies/javase/javase8-archive-downloads.html

  2. extract downloaded jdk file jdk-8u271-linux-x64.tar.gz :-

#tar -xvf jdk-8u271-linux-x64.tar.gz -C /usr/local

  1. configure java manually:-

#update-alternatives --install /usr/bin/java java /usr/local/jdk1.8.0_271/bin/java 100

#update-alternatives --install /usr/bin/javac javac /usr/local/jdk1.8.0_271/bin/javac 100

give any number to your java i.e 100 above command

  1. switch to your java version:-

#update-alternatives --config java

select number according to your java version and press enter

Note: * mean this version currently set or default set

same command use if you installed by yum or rpm package

check java version:-

#java -version

  1. Java home path configure in linux:-

#vim ~/.bashrc

export JAVA_HOME=/usr/local/jdk1.8.0_271

export PATH=$JAVA_HOME/bin:$PATH

save with :wq!

#source ~/.bashrc

now check path

#echo $JAVA_HOME

complete demo:- https://www.youtube.com/watch?v=-v-Zbu6wEkw&list=PL5gKsZrSyQQIBNOTLGedvzlKLD9hKoTmS&index=3