Issue
I am trying to set my machines javac version to 11 from 18.0.2 and I'm doing the following steps
- open ~/.zshenv
- export JAVA_HOME=$(/usr/libexec/java_home -v11)
- source ~/.zshenv
When I check the version, I still get it as 18.0.2. Not sure what I am doing wrong here. Could someone please help me with this? Been stuck on this forever.
Solution
What works like a charme for me is using jenv: https://www.jenv.be/
With jenv you can also switch between different Java versions.
Before using jenv, I relied on the Maven toolchains plugin: https://maven.apache.org/plugins/maven-toolchains-plugin/
Thus, I actually never really worried about JAVA_HOME
on MacOS. Maybe one of these options also is an alternative for you.
Answered By - Andreas Siegel
Answer Checked By - Timothy Miller (JavaFixing Admin)