简体   繁体   中英

Where is Oracle's (Sun's) JDK/JRE installed on Mac OS X 10.8 Mountain Lion?

Oracle(Sun)在Mac OS X 10.8 Mountain Lion上安装JDK / JRE的位置是什么?

/Library/Java/JavaVirtualMachines/根据Mac JDK卸载文档

The Oracle Java SE downloads at: http://www.oracle.com/technetwork/java/javase/overview/index.html

install here on Maverick at least:

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/

this JRE is entirely separate from the ones that Apple has installed, which are under /System/Library/Frameworks/JavaVM.framework/Versions/ as another answer mentioned.

如果在Eclipse之类的东西中设置JRE路径,则需要指向/ home目录,即

/Library/Java/JavaVirtualMachines/<Replace with version>/Contents/Home

On my system, evaluating which java leads me to /usr/bin/java . This in turn is a symlink to:

/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

In case it's relevant, java -version tells me I have 1.6.0_37 installed.

Some of the other answers might be correct but this is what worked for me (which is different and up to date as of January 2016) when installing it on a new computer at the office.

The path as mentioned in another answer is

/Library/Java/JavaVirtualMachines/<Replace with version>/Contents/Home

Here however is a visual guide to getting there, because you can find many directories named "Library". Make sure you are here

在此输入图像描述


then click into JavaVirtualMachines

在此输入图像描述


If you are doing a new setup and just downloaded Android studio, they might have sent you to "Download Java for OS X 2015-001" at https://support.apple.com/kb/dl1572?locale=en_US
That gives you version 1.6.0

在此输入图像描述

That won't work!!!!

I got the error that I needed JDK 7.0 or newer.

I looked for a newer version and found this link from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

在此输入图像描述


I installed it, then selected that one. And it worked

在此输入图像描述

The JDK/JRE as mentioned in previous answers is located in /Library/Java/JavaVirtualMachines/<version>/Contents/Home/. The JRE is dir under this Home. Interestingly browsers doesn't use files from this location for java applet plugin. The location used by browsers is /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/. In fact if you run JRE installer, it updates the files in this location rather than JDK/JRE location.

Enough answers here, but I'm JUST adding a way to find it by yourself

$ sudo find / -name Java
/Library/Application Support/Oracle/Java
/Library/Java
/private/var/root/Library/Application Support/Oracle/Java
/System/Library/Java
/Users/prayagupd/Library/Application Support/Oracle/Java

To be more specific,

$ sudo find / -name jdk*
/Applications/Android Studio.app/Contents/jre/jdk
/Applications/Android Studio.app/Contents/lib/jdkAnnotations.jar
/Applications/IntelliJ IDEA.app/Contents/jre/jdk
/Applications/IntelliJ IDEA.app/Contents/lib/jdkAnnotations.jar
/Library/Java/JavaVirtualMachines/jdk1.7.0_76.jdk

You see /Library/Java/JavaVirtualMachines/ is the place you need to look inside.

And /Library/Java/JavaVirtualMachines/jdk<version>.jdk/Contents/Home/ is your JAVA_HOME

$ ls -ls /Library/Java/JavaVirtualMachines/jdk1.7.0_76.jdk/Contents/Home/
total 39776
    8 -rw-rw-r--   1 root  wheel      3339 Dec 18  2014 COPYRIGHT
    8 -rw-rw-r--   1 root  wheel        40 Dec 18  2014 LICENSE
    8 -rw-rw-r--   1 root  wheel       114 Dec 18  2014 README.html
  216 -rw-rw-r--   1 root  wheel    110114 Dec 17  2014 THIRDPARTYLICENSEREADME-JAVAFX.txt
  344 -rw-rw-r--   1 root  wheel    173559 Dec 18  2014 THIRDPARTYLICENSEREADME.txt
    0 drwxrwxr-x  44 root  wheel      1496 Feb 28 20:13 bin
    0 drwxrwxr-x   9 root  wheel       306 Feb 28 20:13 db
    0 drwxrwxr-x   9 root  wheel       306 Feb 28 20:13 include
    0 drwxrwxr-x  10 root  wheel       340 Feb 28 20:13 jre
    0 drwxrwxr-x  14 root  wheel       476 Feb 28 20:13 lib
    0 drwxrwxr-x   5 root  wheel       170 Dec 18  2014 man
    8 -rw-rw-r--   1 root  wheel       502 Dec 18  2014 release
39184 -rw-rw-r--   1 root  wheel  20061067 Dec 18  2014 src.zip

The version 8 release from Oracle (1.8.0_40-b25) can be found at:

/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/java

FYI: Oracle is not following the practice of making /Library/Java/Current (etc) a link to the latest installed java.

Below is my method of keeping up with versions over time: from my .zshrc file:

108 JAVA_6_HOME=/System/Library/Frameworks/JavaVM.framework/Home
109 JAVA_7_HOME=/Library/Java/Current
110 JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
111 
112 export JAVA_6_HOME
113 export JAVA_7_HOME
114 export JAVA_8_HOME
115 
116 export JAVA_HOME=$JAVA_8_HOME
117 
118 PATH=$PATH:$JAVA_HOME/bin
119 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM