-1

I am using linux subsystem with Debian 10. I installed Java 17 and set the Java homepath to jdk 17. The JAVA_HOME Path ist still java-11, but this isnt even installed.

enter image description here

echo %JAVA_HOME% set set JAVA_HOME=/usr/lib/jvm/java-17-oracle echo %JAVA_HOME%
%JAVA_HOME% set set JAVA_HOME=/usr/lib/jvm/java-17-oracle echo %JAVA_HOME%

I tried to change the home variable permanently, but it does not work.

Well? Still exception enter image description here

Downloaded java versions enter image description here

installed java version enter image description here

How can i change the Java_Home path permanently.

Thank you in advance

Jens
  • 67,715
  • 15
  • 98
  • 113
Avi Rex
  • 1
  • 1

1 Answers1

0

If you install JAVA through your distro's default package manager(for example I use Ubuntu so I install Java(the OpenJDK version of Java) through APT [so the command to install OpenJDK's Java17 for example is sudo apt install openjdk-17-jdk]). Regardless of the version you install via APT, Java will be installed in the /usr/lib/jvm/{java-version-distribution-architecture} path. So, the easiest way to set the JAVA_HOME variable is to edit your .bashrc file and add this inside it using your text editor:

JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export JAVA_HOME
PATH=$PATH:JAVA_HOME/bin
export PATH

Save and close the file after adding this information inside it. Then run the command source .bashrc(to stamp you changes) and the JAVA_HOME will be permanently set. Also note that the .bashrc file is located in the ~/.bashrc(your home). You can confirm the JAVA_HOME variable by using the command echo $JAVA_HOME on the terminal and it should show you the path you just set. I hope this helps