Setting JAVA_HOME on macOS Mojave (10.14) to Lion (10.7)
The installation of Java on recent macOS versions requires additional configuration to set the JAVA_HOME environment variable correctly.
In the absence of a JAVA_HOME setting, add the appropriate line from the following options to your ~/.bash_profile file:
export JAVA_HOME="$(/usr/libexec/java_home -v 1.6)" export JAVA_HOME="$(/usr/libexec/java_home -v 1.7)" export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)" export JAVA_HOME="$(/usr/libexec/java_home)"
Note that you may need to run sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk if you installed openjdk via brew.
Additionally, include the -v flag as suggested by Jilles van Gurp for improved accuracy.
The above is the detailed content of How to Set JAVA_HOME on macOS Mojave (10.14) to Lion (10.7)?. For more information, please follow other related articles on the PHP Chinese website!