Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Java versions running concurrently under Windows

Tags:

java

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 appropriate Java version for different applications, or any other way to set up, what version of Java will be used to run that particular application?

like image 395
Daniel Stanca Avatar asked Nov 07 '08 09:11

Daniel Stanca


People also ask

How can I run two Java versions simultaneously in Windows?

Step 1: Installing Multiple Java Versions. Installing multiple Java versions in parallel is incredibly easy in Windows. You can download and run the installer for each version, which automatically installs the versions in separate directories.

Can I install Java 8 and Java 11 together?

Or, suppose you are working on multiple projects, some of which use Java 8 and some of which are new projects using Java 11. So, in order to work on both of these projects, you will need to install multiple versions of the JDK on your machine and be able to switch between them.

Can I have 2 JDK versions on my machine?

Yes, you can. Just use full path names when invoking javac , java , etc. or set your PATH environment variable to point to the appropriate jdk/bin location. The IDEs usually allow defining multiple JDKs/JREs, and you can choose which one to use for every project.


2 Answers

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 Java 5 is 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 environment variable JAVA6HOME with the value C:\java\java6 (if Java 6 is installed in this directory) and change the batch file calling

%JAVA6HOME%\bin\java ... 
like image 59
reallyinsane Avatar answered Sep 20 '22 10:09

reallyinsane


I was appalled at the clumsiness of the CLASSPATH, JAVA_HOME, and PATH ideas, in Windows, to keep track of Java files. I got here, because of multiple JREs, and how to content with it. Without regurgitating information, from a guy much more clever than me, I would rather point to to his article on this issue, which for me, resolves it perfectly.

Article by: Ted Neward: Multiple Java Homes: Giving Java Apps Their Own JRE

With the exponential growth of Java as a server-side development language has come an equivablent exponential growth in Java development tools, environments, frameworks, and extensions. Unfortunately, not all of these tools play nicely together under the same Java VM installation. Some require a Servlet 2.1-compliant environment, some require 2.2. Some only run under JDK 1.2 or above, some under JDK 1.1 (and no higher). Some require the "com.sun.swing" packages from pre-Swing 1.0 days, others require the "javax.swing" package names.

Worse yet, this problem can be found even within the corporate enterprise, as systems developed using Java from just six months ago may suddenly "not work" due to the installation of some Java Extension required by a new (seemingly unrelated) application release. This can complicate deployment of Java applications across the corporation, and lead customers to wonder precisely why, five years after the start of the infamous "Installing-this-app-breaks-my-system" woes began with Microsoft's DLL schemes, we still haven't progressed much beyond that. (In fact, the new .NET initiative actually seeks to solve the infamous "DLL-Hell" problem just described.)

This paper describes how to configure a Java installation such that a given application receives its own, private, JRE, allowing multiple Java environments to coexist without driving customers (or system administrators) insane...

like image 40
Drikus Avatar answered Sep 18 '22 10:09

Drikus