I try to run a jar file on my user laptop and found that the terminal java version is different from the mac OS version. Downloading JRE is not helping because it’s not set environment variable $JAVA_HOME
This instruction may help to set $JAVA_HOME
without downloading JDK.
- Go to
System Preference > Java
2. Check or update your java version on Update
tab
3. On Java
tab, click button View
to see the java installation location.
4. Copy the path
and remove bin/java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
5. Setup environment variable on your mac
$ echo "export JAVA_HOME=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home" >> ~/.bash_profile
$ source .bash_profile
6. Check your java version
$ java -version
Previously published in https://imantung.github.io at 13 Sep 2017