tags:

views:

346

answers:

2

I am writing a java program using JAVA 6. Our company server is using JAVA 5. They refuse to upgrade it to 6, so the workaround would be install another JRE 6 inside the same machine. They wonder, will installing different version of JRE causes instability?

What the installation process do? Simply copy over the files and setting up environment variable? Will it change any registry or other setting?

+3  A: 

Multiple JREs can reside on the same machine. However, if you install JRE6, that's the same as upgrading to Java 6. Java 6 is (as far as I can tell) able to run all older Java code. However, Java 6 binary (.class and .jar files) can not be executed using Java 5, unless they were compiled to target the previous version.

If you need to, you can target Java 5 using a Java 6 JDK. There are command line arguments for javac that you can use (or incorporate into Ant, and probably other build tools) to specify a target JRE. For example, if you used the -target 1.5 command-line option using your JDK, the .class or .jar files that are produced will be executable using the Java 5 JRE.

It's been a while since I have ran two JREs side-by-side, but unless things have changed, there will be two separate java.exe (on Windows, anyway) files - one for the previous Java 5 JRE and a new one for the Java 6 JRE. Due to naming, only one can be in the path at a time - all of the files have the same names, so you can't include the Java 5 and Java 6 java.exe at the same time and expect the right one to magically run. However, you can leave the Java 5 JRE in your path and manually invoke the Java 6 java.exe when you execute your application.

If you use JAVA_HOME set to the Java 5 JRE and set a new environment variable to the Java 6 Java Home, let's say JAVA_1.6, as long as you properly reference the right environment variable, you should be fine.

Thomas Owens
We got the information about the server almost at the end of the project :( And the java program has already completed and tested. Unless we are given extra time to test our code, otherwise it's safer to install new JRE then downgrade our code.
janetsmith
Unless you used features new to Java 6, you just need to recompile and smoke test the application, if you want to target Java 5. If you used features exclusive to Java 6, then you have to change the code or install a new JRE. However, if you install a new JRE alongside the Java 5 JRE, you have to make sure the server is properly configured to use the proper JRE for the application.
Thomas Owens
Let's say the original configuration JAVA_HOME=path_to_JRE5, and use another variable JAVA_1.6=path_to_JRE6 will it be any problem?
janetsmith
No, not at all.
Thomas Owens
Will it change other setting, e.g. service, registry, or other environment variables? I think JRE is a green software, which can simply move it around without changing the system environment.
janetsmith
I don't know the answer to that. I believe so, but like I said, the last time I ran multiple JREs at the same time was when Java 5 was new.
Thomas Owens
A: 

You can definitely have both. If you are "allowed" maybe you could bundle the jre you want with your app? This URL talks about how.. http://forums.sun.com/thread.jspa?threadID=708451

tim