13

I wanted to get Java running at 1.6xxx - I changed the JAVA_HOME variable and pointed it to the directory C:\Program Files\Java\jdk1.6.0._16.

I restart the PC - and I think I can check which version of Java my machine is pointing at - but it still points to the older version of Java e.g v1.5.0_16

Can you help me rejog my memory on correct setup for Java JDK?

java home

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Vidar
  • 6,548
  • 22
  • 66
  • 96
  • 1
    check your PATH variable and see which version of java is present on that. – Sagar V Sep 29 '10 at 11:03
  • I have tried changing the PATH variable and JAVA_HOME variable to point to the same dir - but I still get the same result using the java -version command - 1.5.0.16 etc. – Vidar Sep 29 '10 at 12:26

4 Answers4

8

You need to reset your path variable to point to 1.6

something like
alt text

Additionally, make sure the variable JAVA_HOME is also set with the above location.

elixenide
  • 44,308
  • 16
  • 74
  • 100
jmj
  • 237,923
  • 42
  • 401
  • 438
  • My Java_Home and my Path Varaible point to the java version 1.6.0_19, but in the cmd java -version shows me java version 1.6.0_20. Because i made an update via the java-Updater? – cuh Sep 29 '10 at 11:09
  • @cuh java-Updater !! interesting, how ? which O.S. ? – jmj Sep 29 '10 at 11:10
  • Windows 7. In the jre/bin Directory start Java Control Panel: javacpl. you can (de-)activate automatic update notifications. My Path points to jdk 1.6.0_19 but java in cmd is linked to the jre6 version 1.6.0_20. – cuh Sep 29 '10 at 11:26
  • @cuh: Is there is a java (a different one) in your system folder by any chance? – Sagar V Sep 29 '10 at 11:27
  • @cuh may be updation process inturrepted and the effect wasn't rolled back properly..may be..i am not sure – jmj Sep 29 '10 at 11:32
  • I have tried changing the PATH variable and JAVA_HOME variable to point to the same dir - but I still get the same result using the java -version command - 1.5.0.16 etc. – Vidar Sep 29 '10 at 12:24
  • @Vidar Have you restart your command prompt after making change ? – jmj Sep 29 '10 at 12:26
  • try executing this at command prompt, echo %PATH% does it contain newer path ? – jmj Sep 29 '10 at 12:39
  • @org.life.java - yes it contains the new path – Vidar Sep 29 '10 at 12:50
  • can you post your output of echo %PATH% – jmj Sep 29 '10 at 12:56
  • @org.life.java - OK, here it is: D:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;c:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.6.0_16\bin;C:\ant\bin;C:\axis2-1.4.1\bin;C:\Sun\jwsdp-2.0\jaxb\bin – Vidar Sep 29 '10 at 13:16
  • @Vidar , I doubt the same thing , there are two executable `java` in path, remove `C:\Program Files\Oracle\jre\1.1.8\bin` from path and then restart command prompt no need to reboot machine – jmj Sep 29 '10 at 13:17
  • @org.life.java - just tried that, made no difference - still 1.5xxx – Vidar Sep 29 '10 at 13:25
  • @Vidar, Then I would suggest reinstalling it. :-) – jmj Sep 29 '10 at 13:27
  • @org.life.java - ok this may be where I went wrong - I didn't exactly install the jdk - I just copied the directory jdk1.6.0_16 from another PC to my PC - thinking that it didn't require any windows specific install program - now I guess it does? Does it alter the registry? – Vidar Sep 29 '10 at 13:39
  • 1
    @Vidar I would strongly recommend you to simply delete that dir, and install it from standard setup. – jmj Sep 29 '10 at 13:44
6

JAVA_HOME is used by other applications, such as Tomcat. Windows just checks the PATH environment variable for locations where it can find the java executable.

Qwerky
  • 18,217
  • 6
  • 44
  • 80
0

This Image will explain all steps. enter image description here

For More Explanation

KarSho
  • 5,699
  • 13
  • 45
  • 78
0

Try this on the cmd shell:

> java -version
java version "1.5.0_16"
> set PATH=%JAVA_HOME%\bin;%PATH%
> java -version
Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
  • 3
    That wouldn't work since you are appending `%JAVA_HOME%\bin` _after_ the existing path list - Windows will still find the older `java.exe` first. Should be `set PATH=%JAVA_HOME%\bin;%PATH%` instead. – Péter Török Sep 29 '10 at 11:12
  • 1
    @Peter, agree, didn't pay attention, the old Java *was* on the path so it has to be added at the beginning for this demo. But obviously, replacing the old entry is the norma solution ;) – Andreas Dolk Sep 29 '10 at 11:27
  • Yes indeed. Btw I wasn't the downvoter - I think your demo idea is good and this issue is trivial to fix. – Péter Török Sep 29 '10 at 11:31