I am trying to run some Java EE examples. Ant is suggesting: "Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre7"

My JAVA_HOME variable is: C:\Program Files\Java\jdk1.7.0_03 when i look at my windows 7 variables

However, my path is (notice the jdk1.6.0_26):

%M2_HOME%\bin;%ANT_HOME%\bin;%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Application Virtualization Client;%M2%;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;%GLASSFISH%;%GLASSFISH_PARENT%;

PATH=C:\Maven\apache-maven-2.2.1\bin;C:\Ant\apache-ant-1.8.2\bin;**C:\Program File s\Java\jdk1.6.0_26\bin;**C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C :\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Applicatio n Virtualization Client;C:\Maven\apache-maven-2.2.1\bin;C:\Program Files\QuickTi me\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\glassfish3\glassfish\bin;C:\gla ssfish3\bin;C:\Sun\jwsdp-2.0\jwsdp-shared\bin

Any suggestions? I'm lost. Do I have to do anything special to get windows to save my path?

Thanks

C:\javaeetutorial5\examples\web\hello2>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre7\li
b\tools.jar
Buildfile: C:\javaeetutorial5\examples\web\hello2\build.xml

-pre-init:

init:

default-ear:

-pre-compile:

bpp-actual-compilation:
     [echo] Compiling hello2
     [echo] javaee.classpath.prefix is: C:\glassfish3/lib
     [echo] is.glassfish.v3 is: ${is.glassfish.v3}
    [javac] C:\javaeetutorial5\examples\bp-project\command-line-ant-tasks.xml:93
: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=las
t; set to false for repeatable builds

BUILD FAILED
C:\javaeetutorial5\examples\bp-project\command-line-ant-tasks.xml:93: Unable to
find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre7"

Total time: 0 seconds
share|improve this question

2 Answers

For eclipse

  • Right Click build.xml ---> Build path ---> configure buildpath ---> select libraries tab
  • click "Add library" ---> double click on [jre system library ] ---> environments ---> installed jres ---> Add ---> standard vm
  • click on directory ---> Browse upto jdk [C:\Program Files\Java\jdk1.7.0_01]
  • finish
  • change the selection jre to jdk ---> click ok
share|improve this answer

You need to point JAVA_HOME to a JDK of Java. As you can clearly read from the error message,

Currently it is pointed to a JRE (Java Runtime Environment):

It is currently set to "C:\Program Files\Java\jre7"

You can download the jdk here:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

share|improve this answer
I figured it out. For some reason I had to log in and out for my PATH to set itself to the jdk1.7 – eric f Mar 29 '12 at 22:11
seems , the problem is with OS registry settings – JavaGeek Dec 8 '12 at 21:35
eric clearly states "JAVA_HOME variable is: C:\Program Files\Java\jdk1.7.0_03" – Kevin Ortman Dec 19 '12 at 0:07
@KevinOrtman no it is not: It is currently set to "C:\Program Files\Java\jre7" last line in the log. – oers Dec 19 '12 at 6:39

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.