Jagadeesh Keerthi
Jagadeesh Keerthi

Reputation: 71

Java path not getting reflected even after changing the PATH variable when working with multiple java versions

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?

Upvotes: 4

Views: 9177

Answers (8)

Ishfaque Ahmed
Ishfaque Ahmed

Reputation: 1

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

Upvotes: 0

Erandaka Anupama
Erandaka Anupama

Reputation: 63

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.

Upvotes: 0

Ravi
Ravi

Reputation: 41

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.

Upvotes: 4

ppuskar
ppuskar

Reputation: 771

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.

Upvotes: 0

Seelenvirtuose
Seelenvirtuose

Reputation: 20608

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.

Upvotes: 10

Jagadeesh Keerthi
Jagadeesh Keerthi

Reputation: 71

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.

Upvotes: 0

Amit Jain
Amit Jain

Reputation: 143

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

Upvotes: -1

Milkmaid
Milkmaid

Reputation: 1754

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.

Upvotes: 0

Related Questions