I use some programs that have known bugs when using Java 1.7.x (default on my computer), issues that would be fixed using Java 1.6. However I also use program that works fine with the default Java and have known issues with older versions.
How can I run the program myprogram specifing the version of Java to use?
1 Answer
There is a shell environment variable, JAVA_HOME that can be set to use a java version from a specific directory. It needs to be exported, and should contain the path of the bin subdirectory of the java version. Also, the same directory should be first (or before /usr/bin) in PATH.
The variable can be set in a script used to start an individual program.
You could find the bin directories of installed versions using something like
$ locate -b '\appletviewer'For details on setting the variable, see Setting JAVA_HOME.
There is a similar variable JDK_HOME for the JDK.