Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Oracle's JVM is only installed in one location. You've been misled!</p> <p>As you've noted, the Java commands in <code>/usr/bin</code> are symlinks to binaries in <code>/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands</code>. The binaries within that directory are stub applications that determine which Java VM to use*, and then exec the corresponding real binary within that VM version. This is why all of the binaries within <code>/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands</code> are almost identical in size, despite the fact that you'd expect them to be implementing quite different functionality.</p> <p>You can see this in action by using <code>dtrace</code>:</p> <pre><code>mrowe@angara:~$ sudo dtrace -n 'syscall::posix_spawn:entry { trace(copyinstr(arg1)); }' -c "/usr/bin/java -version" dtrace: description 'syscall::posix_spawn:entry ' matched 1 probe dtrace: pid 44727 has exited CPU ID FUNCTION:NAME 8 619 posix_spawn:entry /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java </code></pre> <p>The given <code>dtrace</code> invocation prints out the path argument to <code>posix_spawn</code> when it is called by <code>java -version</code>. In my case the stub application has found Apple's Java 1.6 runtime in <code>/System/Library/Java/JavaVirtualMachines/1.6.0.jdk</code> and is invoking that version of the <code>java</code> command.</p> <p>The stub binaries also have another benefit: when they detect that no Java VM is installed they will prompt the user to install one.</p> <p>As for the <code>CurrentJDK</code> symlink, as best as I can tell this for sake of backwards-compatibility with the past when Apple was the only source of the JVM on OS X.</p> <hr> <p>* A combination of factors are considered when determining which Java VM should be used. <code>JAVA_HOME</code> is used if set (try <code>JAVA_HOME=/tmp java</code>). If <code>JAVA_HOME</code> is not set then the list of all virtual machines on the system is discovered. The <code>JAVA_VERSION</code> and <code>JAVA_ARCH</code> environment variables are used, if set, to filter the list of virtual machines to a particular version and supported architecture. The resulting list is then sorted by architecture (preferring 64-bit over 32-bit) and version (newer is better), and the best match is returned.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload