how to set Java 7u9 to be the default JVM on mac osx 10.7.5
Scott Kovatch
scott.kovatch at oracle.com
Mon Nov 5 10:31:10 PST 2012
On Nov 5, 2012, at 8:51 AM, Rick Hillegas <rick.hillegas at oracle.com> wrote:
> I am trying to use Java 7u9 as the default JVM on my macbook pro (running osx 10.7.5). I haven't figured out how to configure my machine so that a Java 7 app will come up when I click on its icon. I would appreciate your advice about what I need to do to configure my machine.
The short answer is, if you want to use Java 7 in a double-clickable application you have to bundle a JRE with your app with AppBundler (http://java.net/projects/appbundler) or javafxpackager, which is part of the JDK. Apple's bundled application support is private API, and not available to Oracle's JRE.
You can bundle your app so it uses the shared Java 7 runtime.
> When I click on the app, I get a popup window telling me that the system couldn't find a 1.7 version of Java. The popup window has a button labelled "Open Java Preferences", but when I click on that button, xyzzy, nothing happens. However, the app does come up if I click on its jar file after navigating to it via Finder's "Show Package Contents" option.
Right -- double-clicking a JAR launches a helper application which does the equivalent of 'java -jar <jar file>'. And since /usr/bin/java finds either the Java 7 JRE or the newest JDK if the 7 JRE isn't available, your app runs in Java 7.
> According to the following webpage, versions of osx like mine are supposed to default to the highest version of Java which the os can find: http://reviews.cnet.com/8301-13727_7-57533880-263/java-preferences-missing-after-latest-os-x-java-update/. But I clearly haven't figured out how to let the os know what that version is.
I re-read that page, and I think this sentence is a bit confusing:
"In addition, the various Java tools Apple includes (such as command-line tools) are configured with reference to the Java runtime with the highest version number, ensuring that Java 7 or later will be used once it is installed, regardless of any other runtimes that may be present."
Here, 'Java runtime' means 'JDK'. The Java 7 JDK (7u9), which you installed, is usable from a command line, but the JRE, which it also installed, is not.
-- Scott K.
----------------------------------------
Scott Kovatch
scott.kovatch at oracle.com
Santa Clara/Pleasanton, CA
More information about the macosx-port-dev
mailing list