Note: If you planning to co-locate JDK 5 alongside JDK 6 on Mac OS X Lion 10.7, refer this post. It worked like a charm on the recent 10.7.3
I recently installed Java for Mac OS X 10.6 Update 4 from Mac Software Update. This update basically installs 1.6.0_24 that contains fixes for security vulnerabilities from 1.6.0_22. I hesitated to apply this update for a while as I did not want to invite any trouble to my existing JDK 5 environment that was co-located with JDK 6 (shipped with Snow Leopard). We use JDK 5 to build Flux 7.10 as it requires 1.5. Now that I am mostly into Flux 7.11 development, which requires JDK 6, I switch back and forth on need basis.
I believe JDK 5 was not officially distributed in Snow Leopard, but JDK 5 was still popular and widely used when Snow Leopard first arrived. JDK 5 was officially retired for quite some time now, and I believe it is widely used in many production environments today. I had to find a way to have both 1.5 and 1.6 co-located on my development environment, and there were so many experiences shared by Java developers across the spectrum. The one which came to my rescue was from OneSwarm. It worked for me just fine and I have been living with that until I decided to upgrade to the latest Java update earlier this month. I knew I was going to mess with my development environment, but not a huge risk though. The upgrade went just fine and as expected the upgrade ripped off my JDK 1.5 and set the system Java preferences to JDK 1.6. I was not worried too much as I was using JDK 6 for Flux 7.11 development. So, I did not bother to look at setting up JDK 5 at that moment.
Today, I had to build Flux 7.10, so I had no other option than fixing my JDK mess. I had to dig through my notes to redo those steps. I wanted to share that experience so if any one runs into a similar requirement, you have a decent solution and update to the latest available JDK 1.5 distribution from Apple that is included in Mac OS X 10.5 updates.
Here are the three simple steps:
1. Download “Java for Mac OS X 10.5 Update 9” from Apple.
2. Assuming all your JDK versions point to your CurrentJDK which is JDK 1.6 under “/System/Library/Frameworks/JavaVM.framework/Versions/”.
Here is how mine looks:
Now, follow these instructions carefully:
cd /System/Library/Frameworks/JavaVM.framework/Versions/ sudo rm 1.5.0
3. You may want to install Pacifist (shareware app), which is handy for extracting OS X packages. Unlike other similar tools, this one allows users to select individual files and folders from the package to be extracted.
Right click on the DMG file (JavaForMacOSX10.5Update9.dmg) that you downloaded in Step 1 and select Open With -> Pacifist. Once the Pacifist opens up, just navigate to System -> Library -> Frameworks -> JavaVM.framework -> Versions -> 1.5.0 in the directory tree and right click on 1.5.0 directory and select “Install to Default Location”.
Here is a screen shot of this step:
After JDK 1.5.0 directory is extracted to the default location, the symlinks under “/System/Library/Frameworks/JavaVM.framework/Versions/” would look different, here is how mine looks after the update:
This shows that JDK 1.5.0 is no longer pointing to your CurrentJDK (JDK 1.6). You may want to reset the symlinks to point to the new 1.5.0 directory.
sudo rm 1.5 sudo ln -s 1.5.0 1.5
Now, you can point your JAVA_HOME to JDK 1.5.0 by setting the JAVA_HOME. For example,
java -version should print:
Voila! JDK 5 is ready to rock on your Mac along side JDK 6. Just switch between the latest and greatest versions you need.
Possibly Related Posts:
- Local Variable Type Inference in Java 10
- Must have Time and Size Log4J appender for your application
- Private interface methods in Java 9
- Java 8 gearing up for release, why Java 8 will be a top contender for Java.next languages in 2014?
- Configuring chunk size in Apache HttpClient 4.3.x