Java is an optional component in recent macOS versions. After installation, the JAVA_HOME environment variable may not be set correctly. Here's how to resolve this issue:
With the Java optional package or Oracle JDK installed, add one of the following lines to the ~/.bash_profile file:
For openjdk installations using brew, execute sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk for the previous commands to work.
Note: The -v flag has been added as suggested by Jilles van Gurp. This ensures that the correct version of Java is selected.
The above is the detailed content of How to Configure JAVA_HOME on macOS Mojave and Older?. For more information, please follow other related articles on the PHP Chinese website!