Multiple Java Versions Running Concurrently Under Windows

Multiple Java versions running concurrently under Windows

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 ...

Can we run multiple java versions in parallel for different purposes?

  1. Manually download and unpack Java
  • https://adoptium.net/releases.html?variant=openjdk11
  • https://www.azul.com/downloads/?version=java-17-lts&os=windows&architecture=x86-64-bit&package=jre

  1. Instead of simply starting java with the
  • java -args commandline,
  • you can start it via /install/path/to/java/bin/java -args
  • or, for windows, use C:\install\location\bin\java.exe -args

You might want to make some start scripts / batch files for that, depending on the exact requirements of your system and Elasticsearch and kafka and possibly other software.

That's it.

one little addition:

If you can NOT directly call java, or the software starts more java apps via the 'default' java, you can also use scripts to manipulate the PATH variables of your system before starting the app. Then you (and your apps) can simply call java -args again.

Switching between different JDK versions in Windows

The set command only works for the current terminal. To permanently set a system or user environment variable you can use setx.

setx JAVA_HOME "C:\Program Files\Java\jdk1.7.0_72" /m

The /m option is used to set the variable system wide (and not just for the current user). The terminal must be run as administrator to use this option.

The variable will be available in all new terminal windows, but not the current one. If you also want to use the path in the same window, you need to use both set and setx.

You can avoid manipulating the PATH variable if you just once put %JAVA_HOME% in there, instead of the full JDK path. If you change JAVA_HOME, PATH will be updated too.


There are also a few environment variable editors as alternative to the cumbersome Windows environment variable settings. See "Is there a convenient way to edit PATH in Windows 7?" on Super User.

running different jre versions on the same machine

Different java version are installed in different directories so running 2 java programs with different JRE version will not make any effect other than that you are running 2 processes of java.

So bottom line, there is no problem with that, it will not slow you down.

Also, java 6 has better performance than 1.4 so if you can run both on 6 its usually better.

Installed two versions of Java, which one takes precedence?

By client I suppose you mean some Windows machine?

You can control which version is used by setting:

  1. The system path to include the java.exe you want used at runtime.
  2. The JAVA_HOME variable to point to the JDK library, only if development takes place on the machine.


Related Topics



Leave a reply



Submit