# can I set an older version of java as a default for certain programs?

I have java 1.6 and 1.7 installed on my computer. I want to use 1.7 for everything except a single webapp that doesn't run on 1.7 well. Can I get some help?

EDIT: On windows but I need a fix for every OS

-

## migrated from stackoverflow.comJul 18 '13 at 16:53

This question came from our site for professional and enthusiast programmers.

what OS are we talking about? – roippi Jul 18 '13 at 15:54
I'm using windows but I need it for every os – user2210099 Jul 18 '13 at 16:03
By "webapp" do you mean a Java applet running in the browser, for which you don't have the code? – Karan Jul 19 '13 at 2:01
This is one of the things doable with applets and java web start. – Thorbjørn Ravn Andersen Jul 25 '13 at 16:35

Make sure that PATH environment variable contains the bin directory of the 1.7 JRE. That way, everytime you use

java SomeClass


you'll use Java 7.

For your specific webapp, launch it using the absolute path of the Java 6 command:

/absolute/path/to/java6/bin/java ...


or

c:\absolute\path\to\java6\bin\java ...


on Windows.

-
This is a noob question but, where do I do this? – user2210099 Jul 18 '13 at 16:01
in your console/shell window. Start menu - Execute - type 'cmd' <Enter>. If you want to be able to double-click on something to start a java app, create a .bat or .cmd script (under windows) or a .sh script (under Linux/MacOS). – user62916 Jul 18 '13 at 16:05

As the answer above states, you can just use the absolute path to the Java compiler for a webapp to use some specific version.

Another option for some applications is to add some switch or setting in an initialization file (typically has a .ini extension on Windows) - e.g. eclipse.ini. Some other Java programs like Sql Developer prompt to choose the version used, if the default is less than ideal.

-

"For every OS" — that is without a doubt not possible to give, but I can add specifics on Debian based systems to the existing answers.

Make sure the wanted Java version is installed and run:

sudo update-alternatives --config java


This will prompt you to choose which of the registered Java versions will be the target of /usr/bin/java, and thus decide the default Java binary.

-