6 Replies Latest reply: Nov 9, 2012 8:49 AM by Mark Jalbert
lscoughlin Level 1 (0 points)

So -- I'm a developer -- how to I switch back to using java 6 on the command line?  or back to java 7 for that sake, if i happened to have installed the jdk8 EAP?

MacBook Pro (17-inch Early 2011), Mac OS X (10.7.5)
  • Mark Jalbert Level 5 (4,630 points)

    I'm using 10.6, so you can try this


    [ZSH-5.0.0] java % /usr/libexec/java_home -V
    Matching Java Virtual Machines (11):
        1.6.0_37-b06-434, x86_64:    "Java SE 6"    /Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home
        1.6.0_37-b06-434, x86_64:    "Java SE 6"    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
        1.7.0-u7-b30-20120831, x86_64:    "OpenJDK 7"    /Library/Java/JavaVirtualMachines/1.7.0u.jdk/Contents/Home
        1.6.0_37-b06-434, i386:    "Java SE 6"    /Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home
        1.6.0_37-b06-434, i386:    "Java SE 6"    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
        1.7.0-u7-b30-20120831, i386:    "OpenJDK 7"    /Library/Java/JavaVirtualMachines/1.7.0u.jdk/Contents/Home
        1.7.0-jdk7u4-b20-20120413, x86_64:    "OpenJDK 7"    /Library/Java/JavaVirtualMachines/1.7.0u4.jdk/Contents/Home
        1.6.0_35-b10-428, x86_64:    "Java SE 6"    /Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home
        1.6.0_35-b10-428, i386:    "Java SE 6"    /Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home
        1.6.0_33-b03-424, x86_64:    "Java SE 6"    /Library/Java/JavaVirtualMachines/1.6.0_33-b03-424.jdk/Contents/Home
        1.6.0_33-b03-424, i386:    "Java SE 6"    /Library/Java/JavaVirtualMachines/1.6.0_33-b03-424.jdk/Contents/Home
    [ZSH-5.0.0] java % java -version
    java version "1.6.0_37"
    Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-10M3909)
    Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

    Assuming that you have multiple Java Virtual Machines listed then export JAVA_HOME to another Virtual Machine


    [ZSH-5.0.0] java % export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.7.0u.jdk/Contents/Home 
    [ZSH-5.0.0] java % java -version
    openjdk version "1.7.0-u7-b30"
    OpenJDK Runtime Environment (build 1.7.0-u7-b30-20120831)
    OpenJDK 64-Bit Server VM (build 23.4-b01, mixed mode)
  • Camelot Level 8 (46,675 points)

    Can't you just use /Applications/Utilities/Java Preferences.app?


    It should show all installed versions and let you choose the active one. Certainly works for regular Java versions, although I haven't tried it with the EAP

  • Mark Jalbert Level 5 (4,630 points)

    The Java Preferences.app has been removed in Lion and Mountain Lion with the latest Java update.

  • Camelot Level 8 (46,675 points)

    Oh, strange. I must be missing an update because I'm running Mountain Lion, and I have Java Preferences.app...

  • lscoughlin Level 1 (0 points)

    This is basically what i've been doing, however I would like to change the general default as well -- I don't normally have to deal with applets etc. but every now and then, _not_ usting the jdk8 EAP would be reccamended...

  • Mark Jalbert Level 5 (4,630 points)

    My understanding is the Java Preference.app is now a preference pane in System Preferences. Also, Apple has published a document on restoring Java6. I don't have the link saved but search the forum and you should find it.