Set different java version for different programs

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?

0

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.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like