2

I see this question has been addressed here Multiple Java versions running concurrently under Windows, I think some things have changed since this question was addressed.

I want to run multiple versions of java on Windows 10. While investigating this I see that Oracle (I think) has modified the PATH env variable on my machine. There are 2 entries:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath

C:\ProgramData\Oracle\Java\javapath

Both of these entries are symbolic links to my default version of java , 1.10 in my case. I think the easiest way to run multiple versions is to remove both of these entries, add a JAVA_HOME env variable and add %JAVA_HOME%\bin to my PATH env variable. When I want to change java versions I just change my JAVA_HOME variable.

I'm wondering if people think this is the best way to accomplish what I want and also does anyone know why there are 2 different entries pointing to symbolic links for java.

4
  • you're overthinking this Commented Oct 10, 2018 at 15:37
  • 1
    actually I thought I was trying to simplify a confusing problem I found. Commented Oct 10, 2018 at 16:04
  • The files in javapath directories are part of the JRE, not the JDK. Commented Oct 10, 2018 at 16:47
  • The files in javapath affect everything because they are in the PATH env variable. So when you run a java program it uses those files. Commented Oct 10, 2018 at 16:50

2 Answers 2

1

I tend to remove all the java variables from the system and put them in the batch file used to start my java app(s)--if you do this you keep complete control across versions.

Even though java apps tend to work on newer java versions, sometimes a program will install an older java version and modify your path/env, so you should probably have your batch file put your desired java bin path at the head of the path variable and overwrite the java_home variable (I think java_opts is used as well and could be set by your batch file).

You can also have a batch file add to the path and then run "CMD" which launches a new shell. This allows you to develop or run java straight from the command line without permanently modifying your environment.

Java never has a simple command line, so I'd think anyone that had to type java -jar … even once would want to build a batch file so they could just launch it like any .exe anyway, so why not set up your environment in there as well?

Sign up to request clarification or add additional context in comments.

Comments

1

On macOS, one can use jENV to manage multiple java versions. There is an alternative of this in Windows - https://github.com/FelixSelter/JEnv-for-Windows/blob/main/jenv.bat

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.