Question or issue on macOS:
I just downloaded Java 7u17 on Mac OS 10.7.5 from here and then successfully installed it. In order to do some JNI programming, I need to know where Java installed on my Mac.
I thought that inside the /Library/Java/JavaVirtualMachines/ folder, there would be a folder called 1.7.0.jdk or something, but then I found that the folder is empty. This was confirmed by running ls /Library/Java/JavaVirtualMachines/ in the Terminal. I’ve tried searching for it to find out if it was installed somewhere else, but that doesn’t seem to be turning anything up.
Could someone please tell me where Java is installed on my Mac?
How to solve this problem?
Solution no. 1:
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, omit the version. e.g. /usr/libexec/java_home
Solution no. 2:
You could use echo $(/usr/libexec/java_home)
command in your terminal to know the path where Java being installed.
Solution no. 3:
Turns out that I actually had the Java 7 JRE installed, not the JDK. The correct download link is here. After installing it, jdk1.7.0jdk
appears in the JavaVirtualMachines directory.
Solution no. 4:
If you install just the JRE, it seems to be put at:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Solution no. 5:
Use unix find function to find javas installed…
sudo find / -name java
Solution no. 6:
Try This, It’s easy way to find java installed path in Mac OS X,
GoTO
1 ) /Library i.e Macintosh HD/Library
2) Click on Library in that we find Java folder.
3) So final path is
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
Hope so this is help for someone .
Solution no. 7:
Java package structure of Mac OS is a bit different from Windows. Don’t be upset for this as a developer just needs to set PATH
and JAVA_HOME
.
So in .bash_profile
set JAVA_HOME
and PATH
as below. This example is for Java 6:
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home export PATH=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin:$PATH
Solution no. 8:
If you type
java -verbose
This also gives the location from which the jars are loaded and hence also the java path.
Solution no. 9:
just write /Library/Java/JavaVirtualMachines/
in Go to Folder –> Go in Finder
Solution no. 10:
Edited: Alias to current java version is /Library/Java/Home
For more information: a link