0
votes

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"

1
I strongly advise you to use a more modern build tool, such as gradle. You can use ant, of course, but it'll be more work. Anyway, your question is too broad. Read the documentation and try something. Ask if you actually have a problem. - JB Nizet

1 Answers

1
votes

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.