The Latest Java Release (Release 4) Makes Java 1.5 The Default Java, As Such, This Hack Is Obseleted. Run Software Update And Grab Any Java Updates To Get Java 1.5 As Your Default Java Compiler (And Runtime Java As Well). You Might Have To Run Mac OS X Update If It Shows Up First Before Java Updates Become Available To You.
Everything worked on HW1, at least with the code that wasn’t supposed to generate compile errors. So that makes me a happy camper.
Thanks a lot Justin, that was freaking awesome! Now NetBeans and JGrasp works for me, I had been coding with Eclipse, which was okay, but I prefered the simplicity of JGrasp, so thanks again.
Another question… my browsers’ have been encountering problems lately, with messages like ‘Firefox has unexpectedly encountered a problem and needs to close.’ Do you know how to remedy things like that?
Thank you so much. I have been searching all over the place without any success. You would think that this would be done either automatically, or somewhat easier to do. Thanks alot. No more school computer labs for me.
Great information - it worked very well.
One other quick question - i noticed when i did the ‘ls’ listing that there is a symbolic link for a directory named ‘A’ . So before setting up for JDK 1.5.0 i had:
Current -> A
CurrentJDK -> 1.4.2
Anyone know if the ‘A’ directory is a sideeffect of the Apple Java update ?
Hi, THis went fine, but when I deleted CurrentJDK I used rm -rf
in error, and thereby deleted 1.4.2. Hopefull this is not serious, but how can
I restore it?
SB
Hey SB, to reinstall 1.4.2, go to Apple’s website, and download the “Java 1.3.1 and 1.4.2 Release 2″ package.
http://www.apple.com/support/downloads/java131and142release2.html
Thanks Justin, nice post.
thanks for this post!
Method 1:
As described above:
- cd /System/Library/Frameworks/JavaVM.framework/Versions
- verify that 1.5 directory exists (before you start messing with things)
- rm Current JDK (this deletes the symbolic link to 1.3/1.4)
- ln -s 1.5.0 CurrentJDK (creates the new symbolic link to 1.5 or newer version)
It appears that “all” the other symbolic links are rerouted based on this change. (The “A” directory appears to be a collection of symbolic links ultimately resolved in “CurrentJDK”.)
OR
Method 2:
Per instructions from Apple:
http://docs.info.apple.com/article.html?artnum=302412
use the new “Java Preferences” app in the /Applications/Utilities/Java directory. This *appears* to reroute a JVM startup request via OSX to 1.5. However, this does *not* reset the default “CurrentJDK” to 1.5 (as in method 1).
Opinion:
I have set both Java Preferences and symbolic linked “CurrentJDK” just to be sure.
Setting the runtime settings via the Java Preferences app works fine for runtime settings, but for those of us who need to compile with Java 1.5 that option is useless for us.
Thanks for the forum, Justin.
In general, it is a bad idea to alter files in /System because Apple can’t anticipate changes you might make. Altering /System can lead to future problems, especially with updates. The preferred way to make changes to system properties is by editing preferences, for instance using the System Preferences control panel.
In this case, you would use the Java Preferences app, and as mentioned in the utility, this suggests behavior to apps. To change IDE preferences, set preferences in the app. To change shell Java properties, edit the .bash_profile in your home directory, making your preferred JDK first in the PATH.
For instance, my .bash_profile looks like this:
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
export PATH=$JAVA_HOME/bin:$PATH:/usr/local/apache-ant-1.6.5/bin:/usr/local/mysql/bin
export CLASSPATH=$CLASSPATH:/Library/Java/Home/lib/ext/mysql-connector-java-3.1.12:/Library/Java/Home/lib/ext/jfreechart-1.0.0-rc1/lib:/Library/Java/Home/lib/ext/Tapestry-3.0.3/lib:/Library/Java/Home/lib/ext/Tapestry-3.0.3/lib/ext:/Library/Java/Home/lib/ext/Tapestry-3.0.3/lib/j2ee:/Library/Java/Home/lib/ext/Tapestry-3.0.3/lib/runtime
Notice in my case that although everything works, my paths to external libraries will break when Apple changes the default JDK to 1.5, because they are in the current default ext. A better paradigm would be to install new JARs into the new ext. Because I am lazy, I am considering intalling external libraries into /Library/Java/Extensions, and then my JAVA_HOME link to 1.5 instead of 1.5.0 really pays off!
Yeah, I’ve been following all of the suggestions and the one that seems the least ridiculous is to edit ~/.profile (so ‘vi ~.profile’ in the Terminal for vi users) and use the following template above what’s already there:
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
export MAVEN_HOME=/usr/local/maven-1.0.2
export ANT_HOME=/usr/local/apache-ant-1.6.5
PATH=”${JAVA_HOME}/bin:${ANT_HOME}/bin:/bin:/sbin:${MAVEN_HOME}/bin:/usr/bin:/usr/sbin”
A typical generic .profile:
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
PATH=”${JAVA_HOME}/bin:/usr/bin:/usr/sbin”
##
# DELUXE-USR-LOCAL-BIN-INSERT
# (do not remove this comment)
##
echo $PATH | grep -q -s “/usr/local/bin”
if [ $? -eq 1 ] ; then
PATH=$PATH:/usr/local/bin
export PATH
fi
This will stick around and be useful for every new Terminal window around, which gives the benefit of permanence (Seriously, have you read the guy who wants everyone to load a shell script every window you want to work with?) and the non-destruction of your /System directory.
It’s a better idea to edit your /etc/profile (requires root access) but those that would be comfortable sudo’ing into edit that file would also likely have known that.
Enjoy.
Thanks; great walk through and it worked for me. Much appreciated!
-Bill
Mmm,
I edit my profile and my environment variables are set.
PATH=/sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/mysql/bin (continued on next line)
:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin:/usr/local/ant/bin:/usr/X11R6/bin
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
but
java -version
java version “1.4.2_09″
${JAVA_HOME}/bin/java -version
java version “1.5.0_05″
What is happening?
I’ve had issues using the bash profile method (doesn’t work, can’t run any command line apps, etc) to make Java 1.5 my default as well. This is a better method (non destrustrive, etc.)., if you can get it to work.
Thanks for the walkthrough, but I prefer to use sudo for each command instead of sudo su root, in case I forget that I’m working in root. Perhaps a future version of this walkthrough should reflect this for us more timid users.
Thanks again!
Thanks a million for your post. it helped me rolling back to 1.4.2, since 1.5 bugged a specific application. Nice job !