wespiserA
wespiserA

Reputation: 3168

Error building java eclipse project via ant from command-line

I'm trying to build an eclipse project with ant via the command line. The build.xml file works great when I run it in java, but when I cd to the project directory(where build.xml is located) and run ant -f build.xml I get the following error msg:

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
Buildfile: build.xml

clean:
   [delete] Deleting directory /home/adam/workspace/pfaat/classes

build:
    [mkdir] Created dir: /home/adam/workspace/pfaat/classes
    [javac] Compiling 502 source files to /home/adam/workspace/pfaat/classes

BUILD FAILED
/home/adam/workspace/pfaat/build.xml:86: 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 "/usr/lib/jvm/java-6-openjdk/jre"

Total time: 0 seconds

Is there a way for me to specify the compiler from the command line w/o changing the build.xml? Again, it works fine when I run it with eclipse, and I haven't found anything in the eclipse or ant manual that should suggest it wouldn't. BTW, I'm running ubuntu 10.04. Thank you very much for your time. Adam

Upvotes: 1

Views: 1802

Answers (2)

Nirmal- thInk beYond
Nirmal- thInk beYond

Reputation: 12054

set PATH that points to tools.jar make sure that it have tools.jar file

use

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin

Upvotes: 1

jajo87
jajo87

Reputation: 1388

Your JAVA HOME path is set to your JRE. Ant needs JDK to work from command line.

Upvotes: 1

Related Questions