I can't find the location of jdk for Java 7 and 8 [duplicate]

I have 3 different versions (jdk) of Java installed: 6, 7 and 8. In

bash_profile:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
setjdk() {
  export JAVA_HOME=$(/usr/libexec/java_home -v $1)
}

However, at

$ ls /System/Library/Java/JavaVirtualMachines
1.6.0.jdk

I see only one version. Where are the 2 other ones? What's the location of their jdks?


Solution 1:

You can see the install locations of the recognized JDKs by using java_home's "-V" option:

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
    1.8.0_31, x86_64:   "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home
    1.7.0_55, x86_64:   "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
    1.6.0_65-b14-466.1, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-466.1, i386:   "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

You see newer JDKs are under /Library/Java/JavaVirtualMachines. I think it was moved out of "System" after Apple stopped developing the OSK JDK themselves and Oracle took over.

Also see /usr/libexec/java_home --help for more options.

Solution 2:

In contrary to the Apple provided Java6 which will be installed to /System/Library/Java and /System/Library/Frameworks, Oracle's Java7 and Java8 are located at /Library/Java/ in several subfolders.