How to manage the Java 6 and Java 7 runtimes in OS X

Problems with Oracle's Java 7 runtime may require OS X users to switch back to Java 6, but currently there is no direct means of doing so.

The transition from Apple's Java implementation to Oracle's with the release of Java 7 is a bit of a problem for many Mac users. While the Java runtime should have the necessary components to run most applications, the implementations differ enough, even in minor details, to make some programs simply throw up their hands and not run, claiming a valid Java installation needs to be run.

As part of its latest updates to Java, Apple has pushed for users to leave the Java SE 6 platform and adopt Oracle's Java 7 runtime. Usually with multiple Java runtimes installed you can use a utility such as Oracle's Java system preferences or Apple's Java Preferences tool to switch between runtimes; however, the differences between the Oracle's and Apple's implementations make them incompatible with these utilities.

Java 7 from Oracle is completely embedded in the Java plug-in that is installed in the /Library/Internet Plug-Ins/ directory on the computer, whereas Apple's version is installed in the /System/Library/Java/ folder and is not bundled in a self-contained package, so that its contents can be accessed more globally by applications that need it. Components of the runtime such as the Internet plug-in are simply linked to so they can be accessed by your Web browsers.

In essence, the basic difference is that one runtime is unpackaged and in a different location than the other runtime, which will require new versions of some Java programs to be released that look for Java in the proper locations.

In the meantime, if you have a Java applet that you need to run on your system and you can't get it working in Oracle's Java 7, then you can re-enable Java 6 without needing a Java runtime manager utility like Apple's Java Preferences. The installation of Java 7 does not remove the Java 6 runtime from OS X, but simply replaces Apple's Java Internet plug-in link with its plug-in package. Therefore, to downgrade and use Java 6, you can replace this package with a link to Apple's Java runtime.

To do this, follow these steps:

  1. Go to the Macintosh HD/Library/Internet Plug-Ins/ folder and delete the file "JavaAppletPlugin.plugin"
  2. Open the Terminal and run the following commands (each on one line):

    cd /System/Library/Java/Support/Deploy.bundle/Contents/Resources/

    sudo ln -sf JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

    Note that Apple does have a Java plug-in reference in its CoreDeploy.bundle package, but in the latest update to Java 6 this plug-in is used to redirect users to download Java 7, so linking to it will not provide a working Java plug-in.

At this point you should have a working Java runtime, but if you also need the Java Web start utility working (to launch locally stored Java applets), then you can run the following command (as noted in a recent Apple Knowledge Base article):

sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws

You can disable Web Start by running the following command (all on one line):

sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javaws /usr/bin/javaws

If after this you would like to get Java 7 running again, you can simply download and reinstall it from Oracle's Java Web site. Future version upgrades to Java will likely be managed properly through Java's system preferences, but for now these steps will have to be taken to specify the Java runtime to use.

Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.

Featured Video

Apple dethroned as world's most highly valued company

An old foe with a new name took the title away from Cupertino. Also, Yahoo's looking at yet another big shake-up.

by Iyaz Akhtar