Mac Java - how to use a different JVM on Mac OS/X 10.4

Mac Java FAQ: I'm currently using Mac OS/X 10.4 with Java 1.5.x. But, for a certain application I need to use a previous version of Java, which I can see is actually installed on the hard drive. Can I use this older Java JVM on Mac OS X 10.4?

Answer: Yes, I was able to do this. The hardest part about this is finding where the previous Java version is installed. There are probably easier ways to do it, but I ended up using the Mac mdfind command, which is the command-line version of Spotlight.

After a lot of grep commands ... I created a shell script that looks like this to let me run this older Mac Java JVM:



java -cp MyApplication.jar

This puts all the Java 1.4.2 information in my PATH and CLASSPATH before the 1.5.x installation, and I ran a test Mac Java application that doesn't use the newer Java 5 syntax, and everything worked fine.