1

How to change java version to jdk1.7.0_80?

java -version java version "1.6.0_41" $JAVA_HOME

$JAVA_HOME: -bash: /usr/java/jdk1.7.0_80: is a directory

I have to update jdk version to 1.7.0_80 and i installed as well,but when i enter java -version,i am getting old version only

kometen
  • 6,536
  • 6
  • 41
  • 51
  • You need sudo access to modify such settings. Else, you should use the canonical java path to run the above command. Have a look at [this](https://stackoverflow.com/a/24641640/5051731) – YetAnotherBot Oct 31 '18 at 08:40
  • What is the type of Linux server (redhat, debian, version?)? What is the source of this jdk (oracle, openjdk, rpm, deb?)? – MariuszS Oct 31 '18 at 08:44
  • I would consider migrating to Java 8 if not Java 11 asap. Java 8 is End of Public updates soon. – Peter Lawrey Oct 31 '18 at 08:52

3 Answers3

1

(1)Use following command to detect installed java version

sudo update-alternatives --config java

enter image description here

(2)Select selection number & Enter

(3)Re-Check java version with

java -version
Asanka Anthony
  • 145
  • 1
  • 13
1

First remove (puge) all installed JDK or JRE on your system

  sudo apt-get purge openjdk-\*    //(for exemple to remove open jdk on ubuntu)

For other steps you can follow steps in this link

Yugerten
  • 878
  • 1
  • 11
  • 30
0

In CentOs: 1. vim /etc/profile , then edit '$JAVA_HOME'. 2. source /etc/profile, make the configuration take effect. 3. java -version, validate version.

Linux-like systems are similar. (If it does'n worked. Reboot.)

Simon
  • 29
  • 7