In regards to the tools.jar, I experienced the following: when downloading ant, it came with open java 7. However, the system I had downloaded, uses Java 8 u 40 (the Oracle version). Therefore, when I pointed the lib/jre via a softlink in linux, to the place of the tools.jar, I got the error, that now the version/subversion was not matching. This because ant was using version 7, and the tools.jar from Oracle was now version 8.
The solution was, to use the above help (with the setting of the JAVA_PATH to become my Oracle version 8u40 of Java), such that both the compiler and the tools.jar file is of same version.
The scenario I am in, therefore has the jdk downloaded as it came from Oracle in my /home/david/Desktop/Android5.0/jdk1.8.0u40 directory - the Android packages as they came in /home/david/Desktop/Android5.0 directory, my Eclipse workspace in /home/david/workspace - and now I hope to be better to go.
The ant-file build.xml is placed in my /home/david/workspace directory - and it is looking like this:
<project>
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/HelloWorld.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="oata.HelloWorld"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java jar="build/jar/HelloWorld.jar" fork="true"/>
</target>
</project>
The java file in this question - HelloWorld.java, is being put into the directory /home/david/workspace/build/src/oata - and it now compiles to its destination you can see above, and from there the jar file is being built too.
True - there are methods where one can make one version of Java pretend to be another - but I didn't want to go there, because I am setting up a build environment where I can do extracts from the repository, build, and storing of the built code into a download site.
The above build.xml sample is slightly modified from the following Ant tutorial for build: https://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html
Guys - hope it works for you too, because ant is really one of the best ways of building, as you can invoke it from the command line, you can make it pick files from the repository first (GitHub or BitBucket etc.), and then you can FTP the compiled result to your preferred download site for developers, you can zip together the code such that you have the version ready and zipped in worst case...