Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I performed a clean installation of Mountain Lion and installed JDK7.

java -version in Terminal returns java version "1.7.0_05" correctly, still Java Preferences and some other Java programs (such as Eclipse) result in prompts to install Java SE 6.

I can start Eclipse perfectly from the command line with Java 7.

Is there a way to get this working without having to install Java 6?

share|improve this question
This is really messed up. Why on earth is this still not fixed? Isn't increased security the main motivation for why Apple gave up control over the Java update procedure? Why then does OSX still prompt me to install an outdated Java? Yikes! –  gentmatt Jan 30 '13 at 15:08
@gentmatt Java 7 is not a simple update for Java 6 - it is more like changing OSs. SOme things will break using the larger version and both major versions are updated for security fixes –  Mark Mar 25 '13 at 17:42
@gentmatt Apple didn't want Java anymore and essentially abandoned it. Oracle chose to pick up the ball. –  Thorbjørn Ravn Andersen Apr 15 '13 at 10:41
It's still stupid to require Java 6, given that it's now deprecated… –  Donal Fellows Jul 27 '13 at 13:54
add comment

3 Answers

up vote 25 down vote accepted

JDK 7 will be installed under /Library/Java/JavaVirtualMachines/1.7.0.jdk, JDK 6 under /System/Library/Java/JavaVirtualMachines.

To trick OS X to accept Java 7 instead of proposing to install Java 6 a simple symlink is enough:

sudo mkdir /System/Library/Java/JavaVirtualMachines
sudo ln -s /Library/Java/JavaVirtualMachines/1.7.0.jdk /System/Library/Java/JavaVirtualMachines/1.6.0.jdk

Most Java Programms will run with this little hack without the need to install Java 6. OS X's Java Preferences (and maybe some others) will not as it seems to explicitly check the version of the JVM when it is started.

share|improve this answer
The second line should not have "su", it should be "sudo ln -s ....." –  David Aug 17 '12 at 8:15
Thanks for the hint, fixed that –  Nicolas Aug 18 '12 at 20:07
I just did a fresh install including JDK 7u9, and it was installed to /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk; the instructions worked fine otherwise. –  Geoffrey Wiseman Nov 22 '12 at 1:05
Watch out for doing the symlink... Apple released 1.6 security update recently. If you apply this update from Apple, the symlink seems to fool the update and installs 1.6 update into where the symlink points to, i.e. Oracle's 1.7. –  user39972 Jan 19 '13 at 18:04
This could break things if a Java program requires Java 6 and not 7 it could break when you use the other version. –  Mark Mar 25 '13 at 17:43
show 1 more comment

Note: if you have something that really needs java6 and won't work with java7, then you might want to hold-off on installing java7. The reason is it might be a little tricky to try to keep both 6 and 7 on same macintosh, as the 7 pkg does some messing with some of the apple-6-java items, as detailed below. So, I'll be looking for some step-by-step instructions on keeping 6 and 7 on same mac before rolling this out... See also http://reviews.cnet.com/8301-13727_7-57533880-263/java-preferences-missing-after-latest-os-x-java-update/ on Oct 18, 2012.

DETAILS The preinstall shell script in jre-7u9-macosx-x64.dmg just removes the Apple pref-pane (as well as plug-in), without warning, below.

PLUGIN_BASEDIR=/Library/Internet\ Plug-Ins
MKDIR=`which mkdir`
# Remove the symlink before installation forcing ystem Preferences.app to refresh its cache
# Actually removes the symlink
if [[ -h "${PREF_PANE_DEST}/${PREF_PANE_NAME}" ]]; then
     ${RM} -rf "${PREF_PANE_DEST}/${PREF_PANE_NAME}"
# Create the /Library/Internet Plug-Ins if not present
if [[ ! -d "${PLUGIN_BASEDIR}" ]]; then
     ${MKDIR} -p "${PLUGIN_BASEDIR}"
# If Apple's plugin is present, then delete it
if [[ -h "${PLUGIN_NAME}" ]] && [[ -d "${PLUGIN_NAME}" ]]; then
    ${RM} -rf "${PLUGIN_NAME}"

=== And the post install script sets up a symlink ===

LN=`which ln`
CHOWN=`which chown`
PLUGIN_FILEPATH=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
PREF_PANE_SRC=/Library/Internet\ Plug-       Ins/JavaAppletPlugin.plugin/Contents/Home/lib/deploy/JavaControlPanel.prefpane
if [ ! -h "${PREF_PANE_DEST}/${PREF_PANE_NAME}" ]; then
    ${LN} -s "${PREF_PANE_SRC}" "${PREF_PANE_DEST}"
${CHOWN} -R root:wheel "${PLUGIN_FILEPATH}"
share|improve this answer
add comment

Mountain Lion with Java 7 alone

You're on the right track … 

Without installing Java 6

… prompts to install, as described in the question, are to be expected.

So my short answer is yes, you can have Java 7 alone; but not without an installation of Java 6.


  1. allow Apple's installation of Java
  2. remove, from the two directories below, the version(s) of Java that are no longer required:



(For a case such as this, I reckon you can safely ignore the usual advice to not interfere with /System stuff.)

share|improve this answer
Java 7 is installed under /Library/Java/JavaVirtualMachines while Java 6 is under /System/Library/Java/JavaVirtualMachines Deleting 1.6.0.jdk from /System/Library/Java/JavaVirtualMachines results in the installation dialog poping up again. What seems to work is to make a symlink 1.6.0.jdk (under /System/...) to the 1.7.0.jdk (under /Library/...). Java Programs that do not check the Java version run fine (Java Preferences blocks at start as it seems to check if Java 5 or 6 is installed) –  Nicolas Jul 31 '12 at 18:46
Cool – would you like to add your own answer? Please vote mine down – I won't take offence – the guess was clearly incorrect for the question, a vote down will help other users to not make similarly mistaken guesses for Java-related issues. –  Graham Perrin Jul 31 '12 at 19:34
add comment

protected by Community Jan 19 '13 at 19:28

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.