wood burning stoves 2.0*
The moose likes Mac OS and the fly likes Java 5.0 - The Missing Installation Instructions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "Java 5.0 - The Missing Installation Instructions" Watch "Java 5.0 - The Missing Installation Instructions" New topic
Author

Java 5.0 - The Missing Installation Instructions

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Java 2 SE 5.0 Release 1 is (finally) available for the new Mac OS (Tiger, 10.4). You can download it here...

http://www.apple.com/support/downloads/java2se50release1.html

As explained on the "About" page, "This update does not change the default version of Java on your Mac from Java 1.4.2 to J2SE 5.0... If you want to change the default Java version for applications and applets, use the new Java Preferences utility that is installed by the J2SE 5.0 update at /Applications/Utilities/Java/J2SE 5.0/."

Ref: http://docs.info.apple.com/article.html?artnum=301073

HOWEVER, this (strange) new Java Preferences utility appears to be for runtime settings only -- not compilation. In other words, it sets the VM, but not the JDK. So if you actually want to compile using Java 5.0 features, you need to perform some reconfiguration after installing 5.0. Here's how...
  • Open Terminal.
  • Because you're going to be modifying System information, you need to identify yourself as the administrator by typing: sudo su root
  • Terminal will prompt for the admin password. Enter this.
  • Change the current directory by typing: cd /System/Library/Frameworks/JavaVM.framework/Versions
  • Within this directory, there is an alias called CurrentJDK. By default, it is aliasing the 1.4.2 directory. You need to remove this alias by typing: rm CurrentJDK
  • Now you need to replace it with a new alias pointing to the 1.5.0 directory instead. Do this by typing: ln �s 1.5.0 CurrentJDK
  • Finally, log out of the session as administrator by typing: exit

  • You're now ready for Tiger on Tiger!

    (Special thanks to Rene, Bear, and Rick for helping me though this in a separate tangled post.)


    "We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
    sscce.org
    Unnsse Khan
    Ranch Hand

    Joined: Nov 12, 2001
    Posts: 511
    Excellent work, Mark!

    I tried your instructions and it worked! YAY! I got Tiger on Tiger, also!

    Your "Missing Installation Instructions" should be converted into a JavaRanch Journal newsletter entry.

    So, if I want to change the JAVA_HOME to JDK 1.4.2 (don't know why I would ever wanted to since JDK 1.5 is backwards compatible), do I have to redo all of these steps and delete the CurrentJDK, all over again?

    Can I just change the JAVA_HOME system environmental variable to point to whatever by specifying the directory under .bash_profile? I wonder why Apple even made it so it had a CurrentJDK directory that needed a symbolic link?

    Interesting...

    Any news regarding MIDP 2.0 support on OS X (10.4 - Tiger)?

    Kindest,
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by Unnsse Khan:
    ... Can I just change the JAVA_HOME system environmental variable to point to whatever by specifying the directory under .bash_profile? ...

    This is what I tried first, but it didn't work. I don't know why, but that CurrentJDK alias seems to be the key. Maybe in future releases, the Java Preference utility will allow switching JDKs too. (I wonder if this is something that could be programmed into the new Automator...?)

    Sorry, I don't know what MIDP is.
    [ May 02, 2005: Message edited by: marc weber ]
    Unnsse Khan
    Ranch Hand

    Joined: Nov 12, 2001
    Posts: 511
    Is there a way to create two shell scripts that would tell the OS to do all of these instructions for JDK 1.4 and 1.5?

    I know that it sounds easy, put when you do the "sudo su root" it going to prompt for a password... Can shell scripts take in args?

    e.g.

    $sh setJDK15.sh <password> ?

    With thanks!
    Rick Beaver
    Ranch Hand

    Joined: Dec 14, 2004
    Posts: 464
    Is there a way to create two shell scripts that would tell the OS to do all of these instructions for JDK 1.4 and 1.5?


    There is - you need to create the shell scripts as root so create the shell script then do a chown on them to root. Next you would need to setuid the script (which I cant remember how to do by the way). setuid means it runs as the owner of the file, not the person executing it so it should run as root.


    ph34r my 133t j4v4 h4><0r1ng sk177z
    Mike McAngus
    Greenhorn

    Joined: Jun 04, 2005
    Posts: 5
    Originally posted by Unnsse Khan:
    Can I just change the JAVA_HOME system environmental variable to point to whatever by specifying the directory under .bash_profile?


    Marc Weber and Unnsse,

    I've played around with Eclipse on both Mac OS X Tiger and on Windows 2000. From my investigations, it appears that Eclipse does not bother with the JAVA_HOME env variable. On both platforms, it simply uses the version of Java that is served up by the OS (On Windows the one that was most recently installed and on Mac the one identified by CurrentJDK).
    Mike McAngus
    Greenhorn

    Joined: Jun 04, 2005
    Posts: 5
    On the "IDEs and other tools" forum, Ilja Preuss points out that the -vm argument allows us to run eclipse under a version of Java that is different from the default.

    This is true, and relatively simple in Windows. Just update the Properties of an Eclipse shortcut to include the -vm argument on the "Target" line.

    However, I'm still having a couple problems on the Mac.
  • I can't figure out how to add "-vm $JAVA_HOME/bin/java" to Eclipse.app. I've tried modifying info.plist and MacOS/eclipse.ini (this seems to be new in the Eclipse 3.1 Eclipse.app) but I keep getting an error saying that there is no JVM at that location.
  • If I run Eclipse 3.1 from the Terminal Eclipse starts up but is unresponsive. I'm using the following commands in Terminal to run Eclipse:

  • $ cd /Volumes/Projects/eclipse\ 3.1RC1/
    $ ./eclipse -vm $JAVA_HOME/bin/java -vmargs -Xms256m -Xmx512m
    Anupam Sengupta
    Greenhorn

    Joined: Jul 07, 2005
    Posts: 1
    To run Eclipse from the command line ... check this out

    http://www.luisdelarosa.com/blog/2004/10/how_to_run_ecli.html
     
     
    subject: Java 5.0 - The Missing Installation Instructions