TrivPants
TrivPants

Reputation: 89

"Unable to find a javac compiler" error in Ant

I have a Java project. It consists of the following hierarchy:

Project:

  • Server (contains the server.java)
  • Client (contains the client.java)
  • Protocol (contains message types in .java files)

I am running this project with Eclipse. And I have gotten to a point that I need to test with a terminal. How can I use the build.xml file to format this so that it will work properly whenever I take it out of the Eclipse and run it in a server, but in the same basic project hierarchy shown above?

I receive the following error:

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar

Buildfile: /home/taylor/Desktop/Java/TCP/build.xml

build-subprojects:

init:

build-project:

[echo] TCP: /home/taylor/Desktop/Java/TCP/build.xml

BUILD FAILED

/home/taylor/Desktop/Java/TCP/build.xml:31: 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-7-openjdk-amd64/jre"

Upvotes: 0

Views: 1856

Answers (1)

martinez314
martinez314

Reputation: 12332

build.xml is an Ant script file. Just install Ant in your OS. Then, at the command-line, go to the directory that contains build.xml and type:

ant

It by default will look for and run the local file called build.xml.

For an example of how Ant build scripts are organized, see here.

Upvotes: 1

Related Questions