tags:

views:

201

answers:

5

I have a couple of applications running on Java 1.4.2_12 and now need to add an new application that uses Java 1.5. Can I have both java versions on a windows server?

+5  A: 

Yes. You just need to make sure that each has the correct version of Java/the JRE on its CLASSPATH, PATH and JAVA_HOME environment variables.

matt b
+3  A: 

Yes: actually JDK or JRE can be just "copied" wherever you want, not "installed" (avoiding putting anything in c:\Windows\System32)

I would also recommend not using global environment variables.

That way, your applications depend entirely on local settings (local to the application), and not on external Java installation side-effects

VonC
The JRE does use some registry values on Windows, so just copying it around is a bad idea unless you are embedding it in an application
Eddie
@Eddie: I am not sure I understand you: I work daily with 2 different JRE copied (one old 1.4, one 6), not embedded, without any problem...
VonC
@Eddie: If you set the env variables before you invoke java.exe, you can ignore the registry entires. It is perfectly safe to copy a Java install; you can even copy it to a machine which does not have the registry entires and it will work.
Aaron Digulla
+2  A: 

Are you sure you have to have the Java 1.4.2_12 apps run using that specific Java VM? Most apps should run fine on the newer VMs, so you might be able to simply have them all use 1.5.

If you do need to use the specific VM versions then you can do what other posters have suggested.

Herms
Yup, code compiled under Java 1.4 will run just fine under 1.5. So you could just run everything under Java 1.5 or even 1.6.
Steve Kuo
Yes my other application state that they do not work on the newer version of JDK and thus the vendor will not support the applications.
veronique
well that's annoying.
Herms
A: 

YES. See above. Of course, running two VMs (of any version) takes twice the RAM.

Chris Nava
A: 

I could suggest you to use Java WebStart, which allow you specific the target J2SE version in the JNLP file. Or; always execute the right version "java.exe" under "Program Files" by absolute path.

You don't have to set CLASSPATH for JRE (and should not in modern JRE). JRE have it own bootclasspath automatically. CLASSPATH is used by your application.

Usually you won't have to set the JAVA_HOME unless your appliaction is looking for resources from JDK\lib\ (e.g. tools.jar which contains compiler)

But I am not sure what's your problem. Are you running client application(swing)? Two Java processes to provide services? or two application sharing same Java application server?

Dennis Cheung