2013-06-17

Finding Java on Your Mac

This neat little article by Mark Needham reveals a utility app, a command line tool, bundled with Mac OS X. The command displays the path to any or all of the Java implementations currently installed on your Mac.

You will find the java_home command stored in the normally invisible folder /usr/libexec.

The upshot…

• To find all the Java implementations on your Mac, run this in a Terminal.app window:
/usr/libexec/java_home -V   

That's an uppercase 'V' in the line above. A lowercase 'v' constrains the scope to a particular generation of Java, as seen in the following items.

• To find the "java_home" path for Java 6:
/usr/libexec/java_home -v 1.6
(that's a lowercase 'v')

• Likewise, to find the "java_home" path for Java 7:
/usr/libexec/java_home -v 1.7

• To find get the current version of Java 6:
/usr/libexec/java_home -v 1.6 -exec java -version

 For example, on my own Mac I get this for 6:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
and this for 7:
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home

No comments:

Post a Comment