0

I have installed java 7 on my machine.

java -version shows that:

java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

javac -version showing

javac 1.6.0_10

When I am trying to build application using Ant it showing me error of "it is recommended that the compiler be upgraded"

How can I update path of javac to point java 7, my JAVA_HOME and PATH variable contain C:\Program Files\Java\jdk1.7.0_09 and C:\Program Files\Java\jdk1.7.0_09\bin respectively.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Neelam Sharma
  • 2,745
  • 4
  • 32
  • 73
  • just an idea: Maybe your PATH variable contains the path to the 1.6 JDK before the path to the 1.7 JDK. Then the first one will be picked up. – Daniel S. Jan 09 '13 at 10:16
  • @DanielS. No I don't have any entry of java 6 in PATH environment variable. – Neelam Sharma Jan 09 '13 at 10:19
  • The following post might help your issue http://stackoverflow.com/questions/3333553/how-can-i-change-the-java-runtime-version-on-windows-7 – justMe Jan 09 '13 at 10:26

1 Answers1

0

Try one of the following:

1) Change the PATH. Set JAVA_HOME before the windows paths. This is because under the windows folder, there is a java.exe that redirects to the last installed jre.

2) Regedit. The key HKEY_LOCAL_MACHINE->SOFTWARE->JAVASOFT->Java Runtime Environment contains the last installed version that the java.exe in the windows folder redirects to. If you change this to the version you want, everything should be ok.

justMe
  • 2,200
  • 16
  • 20
  • Step-1 is correct at my system. Following steps-2 I have checked "CurrentVersion" showing 1.7, but still javac showing 1.6, where to make changes in registry. Screenshot of JRE in regedit- http://neelamsharma.s3.amazonaws.com/registery_java.png , what should I do next? – Neelam Sharma Jan 09 '13 at 11:18
  • did you try restarting your machine after the change for step 1? anyway this is how it should look like: Open the keyHKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment Read the CurrentVersion REG_SZ Open the subkey under Java Runtime Environment named with the CurrentVersion value Read the JavaHome REG_SZ to get the path For example HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment CurrentVersion = "1.6" HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6 JavaHome = "C:\Program Files\Java\jre6" So current JRE is in C:\Program Files\Java\jre6 – justMe Jan 09 '13 at 11:36
  • If you try java -verbose that tells you which rt.jar is used and thus which jre (full path) – justMe Jan 09 '13 at 11:43
  • I have uninstalled java-6 as well as it's all update from my system and Restart my system. But it still showing javac -Version = 1.6.0_10 . while java -version is showing = 1.7.0_09 – Neelam Sharma Jan 09 '13 at 12:07
  • what do you get when you do java -verbose? – justMe Jan 09 '13 at 12:19
  • It gives this path = C:\Program Files\Java\jre7\lib\rt.jar – Neelam Sharma Jan 09 '13 at 12:21
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/22455/discussion-between-neelam-sharma-and-razh) – Neelam Sharma Jan 09 '13 at 12:22
  • That really should be ok if not then I am really not sure what else it might be sorry. – justMe Jan 09 '13 at 12:33
  • an other post I have found and it seems to be suggesting similar things http://stackoverflow.com/questions/8277549/switch-between-java-32-bit-and-java-64-bit – justMe Jan 09 '13 at 12:40
  • If none works then check your path and everything else again if your using 64 bit the path should be C:\Program Files (x86)\Java\jdk1.1.7.0_09\bin. good luck – justMe Jan 09 '13 at 12:50
  • OK I got this problem. When I have checked the version of JavaC available in C:\Program Files\Java\jdk1.7.0_09\bin . It gives the version 1.6.0_10 . Why...I don't know. But when I uninstalling and Reinstalling java. All are working fine. It gives new version of javac. – Neelam Sharma Jan 10 '13 at 05:09