Im using Mac only at work and I need to set JAVA_HOME to proper path of JDK. I downloaded JDK, installed it and now I can't find it anywhere. I was looking at the internet for the solution, but there is no folder Libraries/Java.
-
26found it here: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/ – Sanjay Verma May 30 '15 at 16:26
-
You should use /Library/Java/JavaVirtualMachines so IDEA picks up sources and javadoc properly. At the time of this writing, the correct path was /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home -http://stackoverflow.com/questions/470882/intellij-idea-setup-on-os-x – Sam003 Oct 22 '15 at 00:50
-
On Mac Sierra I've /Library/Java/JavaVirtualMachines which has jdk and System Preferences > Java what's different between these 2 ? – vikramvi Jul 25 '17 at 07:57
-
1This question has a really good 487-vote answer, https://stackoverflow.com/a/18144853/1099571, which is has a very interesting detail not found in any of the answers to https://stackoverflow.com/questions/6141180/mac-os-x-10-6-7-java-path-current-jdk-confusing . I think it's misleading to have a duplicate marker which says "This question already has an answer" over there; maybe that question should point here. Or, someone should make an answer with the best from both questions. – Jim DeLaHunt Dec 09 '17 at 07:52
-
Use `/usr/libexec/java_home -v 1.8` command on a terminal shell to figure out where is your **Java 1.8** home directory. If you just want to find out the home directory of your most recent version of Java run `/usr/libexec/java_home` – genericUser Oct 27 '22 at 08:42
5 Answers
The location has changed from Java 6 (provided by Apple) to Java 7 and onwards (provided by Oracle). The best generic way to find this out is to run
/usr/libexec/java_home
This is the natively supported way to find out both the path to the default Java installation as well as all alternative ones present.
If you check out its help text (java_home -h
), you'll see that you can use this command to reliably start a Java program on OS X (java_home --exec ...
), with the ability to explicitly specify the desired Java version and architecture, or even request the user to install it if missing.
A more pedestrian approach, but one which will help you trace specifically which Java installation the command java
resolves into, goes like this:
run
which java
if that gives you something like
/usr/bin/java
, which is a symbolic link to the real location, runls -l `which java`
On my system, this outputs
/usr/bin/java -> /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java
and therefrom you can read the Java home directory;
if
usr/bin/java
points to another symbolic link, recursively apply the same approach withls -l <whatever the /usr/bin/java symlink points to>
An important variation is the setup you get if you start by installing Apple's Java and later install Oracle's. In that case Step 2 above will give you
/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Commands/java
and that particular java
binary is a stub which will resolve the actual java
command to call by consulting the JAVA_HOME
environment variable and, if it's not set or doesn't point to a Java home directory, will fall back to calling java_home
. It is important to have this in mind when debugging your setup.

- 195,646
- 29
- 319
- 436
-
4
-
55found it here: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/ – Sanjay Verma May 30 '15 at 16:25
-
2
-
2exactly what I was looking for, thanks! Using java_home as keyword, I found a good overview here: https://developer.apple.com/library/mac/documentation/Java/Conceptual/Java14Development/01-JavaOverview/JavaOverview.html – Florenz Kley Jul 28 '15 at 07:31
-
Although good quality, the article is outdated. Apple no longer supports Java and OS X is shipped without it. – Marko Topolnik Jul 28 '15 at 08:13
-
27running `/usr/libexec/java_home -version 1.8` helped me in seconds! – S.M.Mousavi Mar 21 '16 at 15:55
-
[Update] When setting up the JDK in IntelliJ for El Capitan, one would set it to /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/ – womplefrog Aug 11 '16 at 22:03
-
BTW, the [jEnv](http://www.jenv.be/) program might help when it comes to manage many Java versions. – Ludovic Kuty Oct 08 '17 at 07:59
-
This is simply great. Helped me to nail down the exact path to installation. – NKM Jun 18 '19 at 10:05
-
Which Mac version are you using? try these paths
/System/Library/Frameworks/JavaVM.framework/ OR
/usr/libexec/java_home
This link might help - How To Set $JAVA_HOME Environment Variable On Mac OS X

- 703
- 2
- 14
- 26
Have a look and see if the the JDK is at:
Library/Java/JavaVirtualMachines/ Or /System/Library/Java/JavaVirtualMachines/
Check this earlier SO post: JDK on OSX 10.7 Lion

- 1
- 1
-
1That's what I needed to add a JDK 1.8 to my Eclipse install. Thank you! – Alexis Dufrenoy Nov 10 '14 at 12:52
-
1That's the right path for me with JDK 1.8 and Mac OS X Yosemite. Though full path that I needed for set for JAVA_HOME was /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/ – mbbce Nov 25 '15 at 15:38
On my Mac:
/System/Library/Frameworks/JavaVM.framework/Home/
btw, did you tried which java
?

- 18,922
- 9
- 50
- 67
/System/Library/Frameworks/JavaVM.framework/
Also see Java 7 path on mountain lion

- 9,623
- 3
- 43
- 45
-
yes, it shows /usr/bin/java and it seems to not be a symbolic link – Ville Miekk-oja Mar 06 '21 at 17:45