1

In eclipse, the installed JREs having only JDK1.6 and nothing else. But on building the project using gradle, i'm getting the following error.

Caused by: : 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 (x86)\Java\jre7"

I found some solutions over net the the ant might not have the "tools.jar". I tried adding "tools.jar" to the Global Entries of Ant runtime environment. But still the problem exists.

Can anyone help me fix this ?

Sarath
  • 1,438
  • 4
  • 24
  • 40

2 Answers2

1

The error message is quite clear: JAVA_HOME doesn't point to a JDK. Set the JAVA_HOME environment variable to point to a JDK, and not a JRE.

Why do you think changing the environment of the ant runtime would have any impact on Gradle?

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • JAVA_HOME environment variable is set to JDK1.6 only. But still that problem is occuring. – Sarath Jun 04 '13 at 09:08
  • No. The error message says it points to C:\Program Files (x86)\Java\jre7. So it doesn't point to JDK 1.6. Note that if you changed it, you have to restart eclipse, or the cammand prompt, or whatever you use to launch gradle, to make it see the new value. – JB Nizet Jun 04 '13 at 09:11
  • I added the JAVA_HOME routing to the JDK1.6. Still the problem is, Caused by: : 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 (x86)\Java\jre7" at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:128) at org.apache.tools.ant.taskdefs.Javac.findSupportedFileExtensions(Javac.java:961) at org.apache.tools.ant.taskdefs.Javac.scanDir(Javac.java:938) at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:909) ..... – Sarath Jun 04 '13 at 13:19
0

If not JAVA_HOME then probably You have project structure issue. By default, Gradle will look for sources under src/main/java/. If you put your sources somewhere else than this message could happen. First check your JAVA_HOME path if its set to JDK (not JRE!) then check your project structure.

Daniel Pokusa
  • 236
  • 1
  • 10
  • JAVA_HOME environment variable is set to JDK1.6 only. But still that problem is occuring. – Sarath Jun 04 '13 at 09:09
  • Try to set org.gradle.java.home property (gradle.properties). On linux based systems gradle don't use JAVA_HOME variable by default. (I don't know how it works on windows) Can you print your 'gradle -v' output? – Daniel Pokusa Jun 04 '13 at 09:26