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?
-
1Have you also changed the JAVA_HOME variable?user562– user5622014-12-08 11:55:09 +00:00Commented Dec 8, 2014 at 11:55
-
After changing the path, you need to re-launch the command prompt. See..stackoverflow.com/questions/24839819/…Deepak Sharma– Deepak Sharma2016-07-06 11:24:01 +00:00Commented 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?Code-Apprentice– Code-Apprentice2024-01-23 01:43:37 +00:00Commented Jan 23, 2024 at 1:43
8 Answers
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.
3 Comments
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
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
I can think of these places to run from :
- Eclipse :It is easy if using eclipse.(refer google :) )
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.