Many Java applications that use shell scripts to configure their environment use the JAVA_HOME
environment variable to start the correct version of Java, locate JRE JARs, and so on.
In macOS X 10.6, the following paths seem to be valid for this variable
/Library/Java/Home
/System/Library/Frameworks/JavaVM.framework/Home
/System/Library/Frameworks/JavaVM.framework/Versions/Current
Some of these are symlinks to the actual current VM (as defined in the Java Preference pane).
But which one should be used—or is it okay to use any of them?
Best Answer
I just set
JAVA_HOME
to the output of that command, which should give you the Java path specified in your Java preferences. Here's a snippet from my.bashrc
file, which sets this variable:I haven't experienced any problems with that technique.
Occasionally I do have to change the value of
JAVA_HOME
to an earlier version of Java. For example, one program I'm maintaining requires 32-bit Java 5 on OS X, so when using that program, I setJAVA_HOME
by running:For those of you who don't have
java_home
in your path add it like this.References:
Oracle explains the java_home command
An article for configuring the JDK in Spring Tool Suite (Eclipse 2019) on MacOS