We have a couple of applications running on Java 5 and would like now to bring in an application based on Java 6. Can both java versions live together under Windows? Is there any control panel to set the appropiate java version for different applications?
Of course you can use multiple versions of Java under Windows. And different applications can use different Java versions. How is your application started? Usually you will have a batch file where there is something like
java ...
This will search the java executable using the PATH variable. So if there is Java 5 first on the PATH you will have problems running a Java 6 application. You should then modify the batch file to use a certain Java version e.g. by defining a environmentvariable JAVA6HOME with value C:\java\java6 (if Java 6 is installed in this directory) and change the batch file calling
%JAVA6HOME%\bin\java ...
It is absolutely possible to install side-by-side several JRE/JDK versions. Moreover, you don't have to do anything special for that to happen, as Sun is creating a different folder for each (under Program Files).
There is no control panel to check which JRE works for each application. Basically, the JRE that will work would be the first in your PATH environment variable. You can change that, or the JAVA_HOME variable, or create specific cmd/bat files to launch the applications you desire, each with a different JRE in path.
It should be possible changing setting the JAVA_HOME environment variable differently for specific applications.
When starting from the command line or from a batch script you can use set JAVA_HOME=C:\...\j2dskXXX
to change the JAVA_HOME environment.
It is possible that you also need to change the PATH
environment variable to use the correct java binary. To do this you can use set PATH=%JAVA_HOME%\bin;%PATH%
.
Invoking java with "java -version:1.5" etc should run with the correct version of java. (Obviously replace 1.5 with the version you want)
If java is properly installed on windows there are paths to the vm for each version stored in the registry which it uses so you don't need to mess about with environment versions on windows.
If you use java webstart (you can start applications from any URL, even the local file system) it will take care of finding the right version for your application.