Error while installing java from tar.gz file

605 Views Asked by At

I am trying to install java version SE12 form respective tar.gz file. I followed this thread right here, How to set Oracle's Java as the default Java in Ubuntu? (@Barracuda's answer).

When I am trying to execute the following command:

sudo update-alternatives --install /usr/bin/java java ${JAVA_HOME%*/}/bin/java 20000

I am getting following error:

update-alternatives: error: alternative path /usr/java/jdk-12.0.2/bin/java doesn't exist

But ~/usr/java/jdk-12.0.2/bin/java does exist! I don't understand why the error is occurring. Hope someone would help me.

Thanks in advance !


Added part:

The above issue is solved by changing the path in $JAVA_HOME. I followed the steps in the thread to install java. Finally when I check java version it still shows java 11.

When I tried to choose java 12 as default,

sudo update-alternatives --config java

I got the following output:

There are 4 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /home/ubuntu/usr/java/jdk-12.0.2/bin/java        20000     auto mode
  1            /home/ubuntu/miniconda3/envs/vino/bin/java       20000     manual mode
  2            /home/ubuntu/usr/java/jdk-12.0.2/bin/java        20000     manual mode
  3            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  4            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Java 12 is already selected, but when I check java version:

java -version

this is what I get:

openjdk version "11.0.15-internal" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15-internal+0-adhoc..src)
OpenJDK 64-Bit Server VM (build 11.0.15-internal+0-adhoc..src, mixed mode)

Please help me with this.

0

There are 0 best solutions below