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:

#!/bin/sh

JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2
PATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Commands/:${PATH}

java -cp MyApplication.jar path.to.MainClass

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.

 

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.