oussama.elhadri
oussama.elhadri

Reputation: 738

unable to find javac compiler from an executable jar

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:

  1. JAVA_HOME points to the JDK.

  2. I am using ant.jar and ant-launcher.jar.

  3. Eclipse points to my JDK installation.

  4. tools.jar is added to JDK/lib folder

Upvotes: 0

Views: 1678

Answers (3)

oussama.elhadri
oussama.elhadri

Reputation: 738

the solution is to set fork attribute to yes on javac target .

Upvotes: 2

Stephen C
Stephen C

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

Ingo
Ingo

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

Related Questions