Reputation: 738
I am working on a simple java editor that uses ant to call JDK.
On eclipse everything work fine, I am able to build build.xml. The problems is when I export my Editor to an executable jar, and I try to build the build.xml of a project, I get the famous problems:
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"
Important:
If i run my jar Editor from cmd it's work fine ,but if i double click the Editor jar it doesn't work , i get the famous problem (unable to find javac compiler...).
Notice:
JAVA_HOME points to the JDK.
I am using ant.jar and ant-launcher.jar.
Eclipse points to my JDK installation.
tools.jar is added to JDK/lib folder
Upvotes: 0
Views: 1678
Reputation: 738
the solution is to set fork
attribute to yes on javac
target .
Upvotes: 2
Reputation: 719606
Your JAVA_HOME looks like it is pointing to a JRE installation, not a JDK installation. (The error message says it is "C:\Program Files (x86)\Java\jre7"
!)
A JRE does not include any of the Java development tools ... such as the javac
Java compiler that Ant is trying to load / use.
If you really have a JDK installation on your machine, then all you need to do is to change the JAVA_HOME environment variable so that it refers to it ... instead of the JRE. Otherwise, you also need to download and install the relevant JRE.
Upvotes: 1
Reputation: 36339
Perhaps JAVA_HOME does not point to the JDK.
JAVA_HOME is currently set to C:\Program Files (x86)\Java\ jre7
The message is fairly informative and to the point, is it not?
Upvotes: 1