Home > Java > javaTutorial > body text

How to Set JAVA_HOME on macOS Mojave (10.14) to Lion (10.7)?

Barbara Streisand
Release: 2024-11-05 20:25:02
Original
221 people have browsed it

How to Set JAVA_HOME on macOS Mojave (10.14) to Lion (10.7)?

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)"
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!