4

When I am working with multiple versions of Java in my windows machine - 1.6 & 1.7, and when I try to switch from 1.7 to 1.6, and modified the PATH environment variable, it's still showing the 1.7 version only. How can I fix it?

3
  • 1
    Have you also changed the JAVA_HOME variable? Commented Dec 8, 2014 at 11:55
  • After changing the path, you need to re-launch the command prompt. See..stackoverflow.com/questions/24839819/… Commented Jul 6, 2016 at 11:24
  • "it's still showing..." What is still showing? How do you modify the PATH? And then how to you check the version? Commented Jan 23, 2024 at 1:43

8 Answers 8

10

Java installations on Windows machines also copy a java.exe file into the directory C:\Windows\System32 (as well as a javaw.exe and a javaws.exe).

As this directory is usually also part of the PATH environment variable and - also usually - is mentioned before any program directory, you will see the output of the java.exe file that is from the system directory.

The path usually looks like:

PATH = [...];C:\Windows\System32;[...];C:\Program Files\Java\jdk7\bin;[...]

So even if you switch it to

PATH = [...];C:\Windows\System32;[...];C:\Program Files\Java\jdk6\bin;[...]

you will get a "Version 7" output on the console. If you instead change your path variable to

PATH = C:\Program Files\Java\jdk6\bin;[...];C:\Windows\System32;[...]

then you will get the "Version 6" output.

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

3 Comments

for me it was "C:\Program Files\Common Files\Oracle\Java\javapath"
@iamgr007 Have a look at the date. It was back to 2014! The behavior of Java installations on Windows systems changed since then.
yeah I understand! just updating for the peeps looking into this now...
4

In my case the files are copied to the below folder C:\Program Files\Common Files\Oracle\Java\javapath C:\Program Files (x86)\Common Files\Oracle\Java\javapath and both the paths are appended in the system path.

removing the above paths from the system path and setting did the trick.

1 Comment

Welcome to StackOverflow. Please refer: how to answer. Always pay attention to the neatness of the answer.
0

This is because of registry in Windows cause the java executable uses the Windows Registry to locate the default version of Java to run. (registry > JAVA_HOME). If you want to switch between Java dont make installation but only unpacking zip and setting the JAVA_HOME.

Comments

0

In this case, changing the environment variable values only is not sufficient enough to work with. Look for java.exe & javaw.exe files in the Windows/System32 folder. Replace them with those files of the java version bin folder you are actually willing to switch and check the version now. Hope this helps you.

Comments

0

I can think of these places to run from :

  1. Eclipse :It is easy if using eclipse.(refer google :) )
  2. if using command prompt(windows) i would suggest set path vairable for each command prompt i.e. do this :

    e:\somepath> set path=.;c:\pathto\JAVA_HOME\bin

for every CMD instance.

now lets say i have 1.5, 1.6 1.7 installed on my system then i would open three CMDs and issue the above commands for each installations (1.5, 1.6 and 1.7). now i have path variable pointing to my respective jdk installation.

Comments

0

I had the same experience. Using this command, where java from cmd we can get the java.exe path locations. Removing the java.exe for the old java version resolved my problem.

Comments

0

Just copy and replace your 3 Java files:

From this Path: C:\Program Files\Java\jdk1.8.0_331\bin
To this Path: C:\Program Files\Common Files\Oracle\Java\javapath
Files:

  1. java.exe
  2. javac.exe
  3. javaw.exe

Comments

-1

check with set command to see where JAVA_HOME is pointing to...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.