How to force reinstall Java on Mac OS X

If you’ve managed to screw up your existing Java installation on Mac OS X, or you’re looking to downgrade for reason(s) best know to you, here’s a nice and easy way of preventing Mac OS X from telling you it knows best ((The “installer cannot run on this machine because it does not have…” messages)).

Note: This method does not require Pacifist and/ or modification of the installation package in any other way.

Disclaimer: This works on Mac OS X 10.3.9. It may or may not work on Tiger. It may or may not blow up your computer. You run it at your own risk.

And finally, the method:
Step 1 (aka Duh!)
Download the version you need to install on your machine from Apple’s site.

Step 2 (aka My Lucky Day)
Run it and see if it lets you do the needful. If this step is successful, you shouldn’t have been reading this page in the first place. Thanks for wasting my bandwidth. If not, exit the installer and proceed.

Step 3 (aka The Good Stuff)
In Finder, go to folder /System/Library/Frameworks/JavaVM.framework/Resources and move the files “version.plist” and “Info-macos.plist” to a safe place like the Desktop. The moving process might prompt you for password and involve two separate transactions – copying files to the target location and then deleting them from the source.
Hope I have been successful in complicating a simple process.

Step 4 (aka Eureka)
Run the installer again and watch as it proceeds with installation. You didn’t think it would work, did you?

Step 5 (aka Double Check)
Open Terminal and type “java -version”. Is it what you just installed?

Step 6 (aka Optional)
If you answered yes to #5, it’s safe to delete the files you kept as backup. You may, however, want to keep them for reasons best known to you. Leave a comment, below, reassuring everyone that this method actually works.
If you answered no or if step 4 didn’t work for you and you are running Panther, leave a comment so I can take down this post/ blog. If you are running Tiger, please drop in a line to let all the regular readers of this blog (half a dozen Windows users) know that this technique won’t run on 10.4.

Note on disclaimer: In case you are wondering, I was kidding about the blowing up bit. This technique builds on the method described in an official Apple Technical Note. While the note says that removing one file would do just fine, my experiments showed you needed to remove both, especially if you are changing versions. Also, like I said above, you can install any version of Java intended for your OS, not just the one that came with your CD/ DVD like the note says.

Symptoms (aka when to use this method)
This method is known to fix the “Segmentation Fault” and “HotSpot not at correct virtual address. Sharing disabled.” states that some Java installations may find themselves in.