Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is Java Installed on Mac OS X?

Tags:

java

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?

like image 981
Thunderforge Avatar asked Apr 05 '13 04:04

Thunderforge


People also ask

How do I find where Java is installed on my Mac?

In macOS, the JDK installation path is /Library/Java/JavaVirtualMachines/jdk-10.

Where is Jdk 11 installed Mac?

The modular runtime image of JDK 11 contains the following folders: Note: In macOS, the JDK installation path is /Library/Java/JavaVirtualMachines/jdk-interim.

How do I know if Java is installed on my Mac terminal?

Type terminal in the search bar and open it by clicking on the icon in the search results. 3. Once in the command line, run the command: java -version . The output should display the Java version installed on your MacOS.


17 Answers

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

like image 152
gerrytan Avatar answered Oct 05 '22 19:10

gerrytan


You could use

/usr/libexec/java_home

command in your terminal to know the path where Java being installed.

like image 31
Pavithra Gunasekara Avatar answered Oct 05 '22 19:10

Pavithra Gunasekara


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.

like image 29
Thunderforge Avatar answered Oct 05 '22 18:10

Thunderforge


If you install just the JRE, it seems to be put at:

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
like image 42
Morrie Avatar answered Oct 05 '22 20:10

Morrie


Use unix find function to find javas installed...

sudo find / -name java
like image 41
serkan Avatar answered Oct 05 '22 20:10

serkan


Try This, It's easy way to find java installed path in Mac OS X,

GoTO

1 ) /Library i.e Macintosh HD/Library

enter image description here

2) Click on Library in that we find Java folder.

enter image description here

3) So final path is

/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

Hope so this is help for someone .

like image 37
Jaywant Khedkar Avatar answered Oct 05 '22 18:10

Jaywant Khedkar


If you type

java -verbose 

This also gives the location from which the jars are loaded and hence also the java path.

like image 23
jones j alapat Avatar answered Oct 05 '22 20:10

jones j alapat


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
like image 38
Bimales Mandal Avatar answered Oct 05 '22 19:10

Bimales Mandal


just write /Library/Java/JavaVirtualMachines/
in Go to Folder --> Go in Finder

like image 26
Mina Fawzy Avatar answered Oct 05 '22 20:10

Mina Fawzy


Edited: Alias to current java version is /Library/Java/Home

For more information: a link

like image 40
manny Avatar answered Oct 05 '22 20:10

manny


type which java in terminal to show where it is installed.

like image 42
Pranay Aryal Avatar answered Oct 05 '22 19:10

Pranay Aryal


For :

  • OS X : 10.11.6

  • Java : 8

I confirm the answer of @Morrie .

   export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home;

But if you are running containers your life will be easier

like image 45
Abdennour TOUMI Avatar answered Oct 05 '22 18:10

Abdennour TOUMI


I have just installed the JDK for version 21 of Java SE 7 and found that it is installed in a different directory from Apple's Java 6. It is in /Library/Java... rather then in /System/Library/Java.... Running /usr/libexec/java_home -v 1.7 versus -v 1.6 will confirm this.

like image 23
Tony Kroch Avatar answered Oct 05 '22 20:10

Tony Kroch


I tried serkan's solution, it found java 7's location on OS X Mavericks. it is resided in "/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/" but to make it the default JDK I had to set JAVA_HOME system variable in .bash_profile in home directory to "/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/" so its up and running now thanks to serkan's idea

like image 35
Mehdi Ijadnazar Avatar answered Oct 05 '22 20:10

Mehdi Ijadnazar


In case you have multiple Java versions installed, use:

$ /usr/libexec/java_home --verbose

or:

$ /usr/libexec/java_home -V (That's an uppercase V!)

to list all versions and architectures.

Sample output:

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
    12.0.1 (x86_64) "Oracle Corporation" - "Java SE 12.0.1" /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
    1.8.202.08 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_282 (x86_64) "Amazon" - "Amazon Corretto 8" /Users/username/Library/Java/JavaVirtualMachines/corretto-1.8.0_282/Contents/Home
    1.8.0_202 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
like image 22
Derek Lee Avatar answered Oct 05 '22 18:10

Derek Lee


Try to check in here
/Library/Java/JavaVirtualMachines

like image 27
Tal Hakmon Avatar answered Oct 05 '22 18:10

Tal Hakmon


if you are using sdkman

you can check it with sdk home java <installed_java_version>

$  sdk home java 8.0.252.j9-adpt
/Users/admin/.sdkman/candidates/java/8.0.252.j9-adpt

you can get your installed java version with

$ sdk list java
like image 38
user9869932 Avatar answered Oct 05 '22 20:10

user9869932