I have a project set up like this;
Project
-src
-com
-top
-classes
Class_3.java
Class_4.java
-utils
Class_5.java
Class_6.java
Class_1.java
Class_2.java
-data
various files
-libs
lib_1.jar
lib_2.jar
lib_3.jar
lib_4.jar
build.xml
class_1.java contains the main class, libs contains external dependencies, data contains various images, text files etc…
I have been trying to write an Ant build file to make a distributable JAR file but am having difficultied pulling in all the required libraries etc…
This is where I am up to.
<?xml version="1.0"?>
<project name="Project" default="jar">
<property name="libsSrc" value="libs"/>
<property name="build" value="build"/>
<property name="classes" value="build/classes"/>
<property name="jar" value="build/jar"/>
<property name="libs" value="build/libs"/>
<path id="classpath">
<fileset dir="${libsSrc}" includes="*.jar"/>
</path>
<target name="clean" description="remove intermediate files">
<delete dir="build"/>
</target>
<target name="compile" description="compile the Java source code to class files">
<mkdir dir="${classes}"/>
<javac srcdir="." destdir="${classes}" classpathref="classpath">
<compilerarg line="-encoding utf-8"/>
</javac>
</target>
<target name="jar" depends="compile" description="create a Jar file for the application">
<mkdir dir="${jar}"/>
<jar destfile="${jar}/App.jar">
<fileset dir="${classes}" includes="**/*.class"/>
<manifest>
<attribute name="Main-Class" value="com.top.Class_1"/>
</manifest>
</jar>
</target>
</project>
This doesn’t work currently.
It compiles with no errors but doesn’t include the required dependencies and the JAR cannot find the main class. How can I fix it?
Seems to do the trick but the line;
seems to do nothing, I have a few text files containing UTF-8 encoded characters that are read into strings and displayed that are not showing properly; dσ/dΩ shows as dÃ/d©. I will ask that in another question though.