The output of any Java command on Mac OS X is prefixed with "Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...". For example,
$ java -version Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java... java version "1.6.0_43" Java(TM) SE Runtime Environment (build 1.6.0_43-b01-447-11M4203) Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01-447, mixed mode)
In macOS, the JDK installation path is /Library/Java/JavaVirtualMachines/jdk-10. jdk/Contents/Home . The root directory of the JDK software installation.
In summary, /usr/bin/java finds all of the JVMs under /Library/Java/JavaVirtualMachines and ~/Library/Java/JavaVirtualMachines and points to the latest JVM that has Contents/Info. plist . If you rename that file in a JVM to, say, Contents/Info.
The Java home environment variable is set incorrectly, possibly due to instructions from an outdated guide (e.g. EC2 Command Line Tools).
Wherever you set JAVA_HOME (e.g. .bashrc), change it to:
export JAVA_HOME="$(/usr/libexec/java_home)"
As of Mac OS X 10.5, that executable is the supported method of setting JAVA_HOME.
https://developer.apple.com/library/content/qa/qa1170/_index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With