Friday, September 13, 2013

Java 7 and Snow Leopard (OSX 10.6... )

As said in the title I needed to install Java 7 on my OSX 10.6.8 aka Snow Leopard. Of course as usual I downloaded Java 7 JDK and run installation program and guess what, it did not work.I was getting a message saying that I need to have at least Lion version of OSX in order to run Java. I have know idea why is that but sounds pretty stupid.

So lets go straight to business and take look how I did it.

Navigate to /System/Library/CoreServices and edit SystemVersion.plist to change following properties:

ProductUserVisibleVersion = 10.7.8
ProductVersion = 10.7.8 

As you would guess above will change version of your OSX as seen by Installer. To be sure that you changes were applied open up About This Mac Window and check if it matches. Now installation should work without any problems.

After installation go to console and type in.

java -version

If Java version remained the same as it was before (in my case I had Java 6 )  you need to remove soft link :

/Library/Java /Home

and create new one with same name but pointing to newly installed Java which was in my case:

/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home

Hope this helps someone and don't forget to change back version in SystemVersion.plist!


UPDATE:

I forgot to mention one more important thing and that is to change softlink in /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK . That softlink should point as well to new JDK location.
Also in some cases (as noticed by Alejandro) you will need to update order of virtual machines on your computer: double click on /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk to load Java Preferences and change order of VMs.


Happy coding.

Niksa Jakovljevic

39 comments:

  1. Installing java succeeds like described.
    When I check version with OSX Terminal I get 1.7.0_40
    But no java programs work anymore.

    With 'console' you mean java console I suppose?
    When I go to OSX System preferences >Other >Java
    the Java Control Panel should open, but nothing happens.
    Do I miss something?

    ReplyDelete
    Replies
    1. he means the Console application in /applications/utilities

      Delete
  2. Yes you are right , I forgot to mention one more important thing and that is to change softlink in /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK . That softlink should point as well to new JDK location.

    ReplyDelete
  3. Hi Niksa,
    I followed your instructions (even adding the softlink in /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK) but it didn't work. Then I double-clicked on /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk and appeared the Java Preferences that allowed me to change order of JDKs. With this it worked for me.
    Cheers,
    Alejandro

    ReplyDelete
    Replies
    1. Hi Alejandro,

      glad to hear it worked for you, I will update the post with your comment.

      All the best,

      Niksa

      Delete
  4. yes, please more comment, because my mac, is in italian language and I need to translate, everything.. and get the words how was translated into an italian mac... pretty hard.. sometimes..

    ReplyDelete
  5. I have a problem, maybe is a silly problem, but I don't get, I try to change from 10.6.8 to 10.7.8 with x code, text, etc.. and all time, it tell me "The document “SystemVersion.plist” could not be saved. " why? I change the property.. inside.. but nothing. Any idea. I am sure that is a easy and basic question, but I don't know.

    ReplyDelete
    Replies
    1. Hi Enrico,
      yes thats permissions thing. You can copy SystemVersion.plist somewhere, edit it and than copy back and replace - you will need to enter admin credentials to be able to replace the file.

      Cheers,

      Niksa

      Delete
  6. Dude, please put all the steps in the correct order and *before* your "UPDATE". I tried so many things before "Hope this helps someone" to get it to work that I totally screwed up my Java and had to reinstall the whole system before I read further. When you find something wrong with instructions you should edit the instructions not tack on an update at the end.

    ReplyDelete
  7. How do you change a soft link?

    ReplyDelete
    Replies
    1. You just delete it and create new one. I was doing from command line with 'rm' command to delete and then 'ls' command to create soft link. I guess you can easily google unix/linux basics.

      Delete
    2. Do you mean "ln -s"?

      Delete
  8. I did it, thank you very much.
    I noticed that, if you don't change SystemVersion.plist back to 10.6.8 jdk7 works fine. However, with all the indications (those of Alejandro too) everything was fine.
    Finally I have jdk7 on my beloved Snow Lepard :-)

    ReplyDelete
  9. Superb dude ! Thanks a lot. Awesome ! It worked for me :)

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. It works!
    Personally I would suggest a restart after the completion of all steps (or just after the new Java installation) and re-check the version 'java -version'
    I say this because prior to restarting the system 'mac os' would not allow me to open the jdk1.7.0.jdk stating some error message, which was the last critical step in order to make everything work, but after the restart I could normally open 'Java Preferences' and rearrange everything to the desired order.

    LMO the program I was trying to run is Program AB (https://code.google.com/p/program-ab/), I am trying to create an AI bot with AIML2 (I already have one running on AIML1 http://emma.feltcollective.com)
    right now it is in test mode, anyway, I still can not run the run.sh
    after succesfully installed the new jave now I get this error: Error: Could not find or load main class Main
    I was wondering if you could give a hand with this.
    Thank you
    Byron

    system: downgraded mac os x 10.6.8 on an Intel Core i7 13'' mac book pro

    ReplyDelete
  12. Hi I just came to say that I am having some trouble with this method so I was wondering if you could make a tutorial video or and installer.
    Plese reply soon.
    Thank you

    ReplyDelete
  13. To everyone having trouble with this method:

    Use JDK 1.7.0_25 or lower.

    ReplyDelete
  14. Warning: this method did not work for me and ruined my existing Java installation.

    OS 10.6.8; jre-7u51-macosx-x64.

    Apparently the Java installer did not install JDK 1.7 (is nowhere on disk), but did replace other parts of the installation, like Java Updater, browser plug-ins, and obscure configuration files. For example, Java applets no longer run ("Java is required..."), and while the CrashPlan app appears to be working, the Java background process no longer detects and backs up changed files. On the other hand, NetBeans seems to run normally.

    I have re-installed from Apple's JavaForMacOSX10.6update17, without restoring proper functionality. Still working on it. Fortunately I have a CCC backup of the system.

    It may be that the above method worked correctly with earlier versions of the Java 7 installer, but no longer does.

    YMMV, as always.

    ReplyDelete
    Replies
    1. I had the same experience. A new install (using either Pacifist or manually changing the OS version in the prefs file to trick the installer into running) did not properly install the new version and made the old version inoperable. I had to use the steps from the link below to reinstall Java 6. This was using the current Version 7 Update 67 of Java.

      Anyone know how to do this with the current version? Or maybe I can try with Version 7 Update 40… a little scared now since it messed up my current Java install.

      Delete
  15. Followup: I restored the original Java 6 installation using the steps in this answer:
    http://stackoverflow.com/a/14808671/3238573

    The key is to first delete the Java 1.6 VM and then install Apple's Java update.

    ReplyDelete
  16. do any of you have 32bit machine?

    ReplyDelete
  17. At one time, Java 1.7 had security issues, and the Java SE 7 download page currently says "WARNING: These older versions of the JRE and JDK are provided to help developers debug issues in older systems. They are not updated with the latest security patches and are not recommended for use in production." (URL below.)

    Is there a known security risk using the current version of 1.7 on OS X 10.6.8?

    http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html

    ReplyDelete
  18. Your instructions helped a lot. Thanks !

    ReplyDelete
  19. how i can create a soft link?? simply with a folder?

    ReplyDelete
  20. These instructions worked flawlessly for me today in installing JDK 7u67 (on my 10.6.8 machine, of course). Thanks!!!

    ReplyDelete
  21. If you have problems "Java is required ..." when starting jdk for changing order just try to edit the system version back to 10.6.8 - it tries to start Java 6 which does not run if system pretends to be 10.7.8. Then you can choose versions.

    ReplyDelete
  22. Cannot open the Java control panel. Followed all the steps. version 71. Terminal says Java is working. Firefox sees the plugin in about:plugins, says it's enabled. It shows up in Java Preferences and I put it at the top. Repaired permissions. Deleted Java stuff from XProtect plist. Nothing seems to be able to get that control panel to open. Java isn't working with web applets either.

    ReplyDelete
  23. Follow-up... The Java plug-in crashes on this page of test applets hosted by a university: http://www.cis.upenn.edu/~matuszek/General/JavaVersionTests/JavaTests.html

    So, the control panel doesn't open and the Java plug-in also crashes. I was using the latest Firefox.

    ReplyDelete
  24. I followed the steps one by one and managed to install version 1.7.0_71.
    Problem is that now, all my java applications stopped working. This is the error I get:

    2014-10-30 17:11:20.446 java[1101:50b] *** NSInvocation: warning: object 0x1097a53c0 of class 'ThreadUtilities' does not implement methodSignatureForSelector: -- trouble ahead
    2014-10-30 17:11:20.448 java[1101:50b] *** NSInvocation: warning: object 0x1097a53c0 of class 'ThreadUtilities' does not implement doesNotRecognizeSelector: -- abort
    Trace/BPT trap

    ReplyDelete
    Replies
    1. I am glad I found this as I see the same issue. The update allows you to compile Java 7 class files and it allows some apps to run that require Java 7, but other Java functionality is broke.

      Delete
  25. This comment has been removed by the author.

    ReplyDelete
  26. This comment has been removed by the author.

    ReplyDelete
  27. Theres no way this will work, I cannot change the version because of security
    I believe that apple may have added securities to the version changing because of how many people have done it, not sure though.
    Any way to fix this?

    ReplyDelete
  28. Using the special version of Java from http://baderlab.org/InstallingCytoscape32OnMacOSXSnowLeopard works better than anything else suggested here.

    ReplyDelete
  29. I got an error like this "NSInvocation: warning: object 0x10ace93c0 of class 'ThreadUtilities' does not implement methodSignatureForSelector: -- trouble ahead" after starting up a Java app from the console. The JDK versuin was too high, so I downgraded to 1.7u25 and it worked. Downgrading also means removing the newer JDK, see http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html

    ReplyDelete
  30. Niksa! THANK YOU.

    STILL on 10.6.8 (don't ask) and allegedly need 7 for training tomorrow...

    ...your instructions still work like a champ. I followed the suggestion to just double click to activate/drag-n-drop the Java Preferences version ordering and java -version now reports correctly the new install.

    T h a n k s

    ReplyDelete
  31. I'm not sure if this method works well. The possibility to crash in your system is high even though java version showing correctly with latest install. And some odd files work well with application for a while, but others not. Because, almost every application depend from java.

    ReplyDelete
  32. This also worked for java 8 in my computer.

    ReplyDelete