'Why my uninstalled jdk version still shows in java -version?
In my project which need jdk 1.8, but there is default openjdk 17 in my mac. So I remove it from Library/Java/JavaVirtualMachines. But when I run java -version it still shows my default jdk version is openjdk 17. And when I run /usr/libexec/java_homeit shows /Users/lidu/Library/Java/JavaVirtualMachines/openjdk-17/Contents/Home. But I am sure that there isn't a directory called openjdk-17 in the path /Users/lidu/Library/Java/JavaVirtualMachines/.
And when I run export JAVA_HOME=$(/usr/libexec/java_home -v "1.8.0_331")it can be changed to jdk 1.8 but in the next time when I create a new terminal, it still shows the default jdk version is open jdk 17.
Solution 1:[1]
export will only persist in the terminal, if you run it manually.
Add the export JAVA_HOME command in .profile file at home directory, so that it will persist in every newly created terminal.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
