![Run java on mac os](https://kumkoniak.com/8.jpg)
![run java on mac os run java on mac os](http://www.bartneck.de/wp-content/uploads/2017/06/check-the-installed-version-of-java-1.png)
bash: /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home: is a directory 192:~ zhaosong$ $(/usr/libexec/java_home)
![run java on mac os run java on mac os](https://news-cdn.softpedia.com/images/news2/Apple-Releases-Java-2012-005-for-OS-X-10-7-and-10-8-Update-10-for-Snow-Leopard-2.png)
Run this command in the terminal like below, you can get the real JDK installation directory. Why this command in macOS? This is because $(/usr/libexec/java_home) can return the real JDK installation home directory.export JAVA_HOME="$(/usr/libexec/java_home)" In vim, press the esc key first then press i key to insert text, click esc then :wq to save and quit. bash_profilecommand in terminal and add below export command in it. You can also run ls -alto list all files under your home directory.
![run java on mac os run java on mac os](https://humairahmed.com/blog/wp-content/uploads/2014/12/maxosx_security_warning_java-e1419452721933.png)
bash_profile to make sure the file exists. Run cd ~ in terminal to go to the current user home directory. bash_profile file, this file is saved in the current user’s home directory. First, all environment variable settings are saved in the current user’s.
![Run java on mac os](https://kumkoniak.com/8.jpg)