Hokester
asked on
Ant compiled program not showing source code line in errors
When i compile my program and build the jar package using ant, and then execute that jar package and hit an error, the displayed java error doesnt seem to know about the source code. It prints out the stack trace, but doesnt include any line numbers so i dont really know where the error was. When i run the same code in my IDE, JBuilder, and hit an error, it always tells me where in the source code the error was. Here is my build.xml file for my package. Any suggestions on what to change so it can reference the source code line number when errors occur?
<?xml version="1.0"?>
<project default="dist" name="Project Eric">
<description>Stat Program</description>
<property name="srcDir" location="/usr/local/jakar ta/webapps /NBNFBA/WE B-INF/src" />
<property name="buildDir" location="build"/>
<property name="distDir" location="dist"/>
<property name="tomcat.lib.dir" value="/usr/local/jakarta/ common/lib "/>
<property name="mysql.lib.dir" value="/Library/Java/Exten sions"/>
<path id="java.libs">
<fileset dir="${tomcat.lib.dir}" includes="servlet-api.jar" />
<fileset dir="${tomcat.lib.dir}" includes="mail.jar"/>
<fileset dir="${tomcat.lib.dir}" includes="activation.jar"/ >
<fileset dir="${mysql.lib.dir}" includes="mysql-connector- java-3.0.1 0-stable-b in.jar"/>
</path>
<target name="init">
<tstamp/>
<mkdir dir="${buildDir}"/>
<mkdir dir="${distDir}"/>
</target>
<target name="compile" depends="init">
<javac srcdir="${srcDir}" destdir="${buildDir}" classpathref="java.libs"/>
</target>
<target name="dist" depends="compile">
<jar destfile="${distDir}/packa ge-${DSTAM P}.jar" basedir="${buildDir}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="fantasy.gui.Main"/>
<attribute name="Class-Path" value="mail.jar activation.jar servlet-api.jar mysql-connector-java-3.0.1 0-stable-b in.jar "/>
</manifest>
</jar>
<jar destfile="${distDir}/packa ge-src-${D STAMP}.jar " basedir="${srcDir}"/>
</target>
<target name="clean">
<delete dir="${buildDir}"/>
<delete dir="${distDir}"/>
</target>
</project>
<?xml version="1.0"?>
<project default="dist" name="Project Eric">
<description>Stat Program</description>
<property name="srcDir" location="/usr/local/jakar
<property name="buildDir" location="build"/>
<property name="distDir" location="dist"/>
<property name="tomcat.lib.dir" value="/usr/local/jakarta/
<property name="mysql.lib.dir" value="/Library/Java/Exten
<path id="java.libs">
<fileset dir="${tomcat.lib.dir}" includes="servlet-api.jar"
<fileset dir="${tomcat.lib.dir}" includes="mail.jar"/>
<fileset dir="${tomcat.lib.dir}" includes="activation.jar"/
<fileset dir="${mysql.lib.dir}" includes="mysql-connector-
</path>
<target name="init">
<tstamp/>
<mkdir dir="${buildDir}"/>
<mkdir dir="${distDir}"/>
</target>
<target name="compile" depends="init">
<javac srcdir="${srcDir}" destdir="${buildDir}" classpathref="java.libs"/>
</target>
<target name="dist" depends="compile">
<jar destfile="${distDir}/packa
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="fantasy.gui.Main"/>
<attribute name="Class-Path" value="mail.jar activation.jar servlet-api.jar mysql-connector-java-3.0.1
</manifest>
</jar>
<jar destfile="${distDir}/packa
</target>
<target name="clean">
<delete dir="${buildDir}"/>
<delete dir="${distDir}"/>
</target>
</project>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
check the dir where the source code is. Maybe it is unreachable.
ASKER
i know the source code is reachable because the compile works and the package is successfully built. ill give the debug try an attempt tonight when i get home.
Good luck.
hi
u can try like this
<javac srcdir="../com/xxx/xxx/xxx /dao" destdir="${build.jar}/clas ses"
debug="true" debuglevel="lines,vars,sou rce"/>
this will show you the line number when u use the classes anywhere.
thanks
Kiran
u can try like this
<javac srcdir="../com/xxx/xxx/xxx
debug="true" debuglevel="lines,vars,sou
this will show you the line number when u use the classes anywhere.
thanks
Kiran
ASKER
gdrnec,
this worked exactly like i wanted it to. Now that i knew the command i found all kinds of information about what you said in the ant documentation. kiranhk, i gave the points to gdrnec because you mostly said the same thing, he just beat you to it. It is worth noting that if anyone reads this in the future that i had to delete my build directory because the files needed rebuilt using this debug on feature. When i originally tried the solution it did not work. I deleted the build directory, so that everything had to be rebuilt, and then it worked just like i wanted.
this worked exactly like i wanted it to. Now that i knew the command i found all kinds of information about what you said in the ant documentation. kiranhk, i gave the points to gdrnec because you mostly said the same thing, he just beat you to it. It is worth noting that if anyone reads this in the future that i had to delete my build directory because the files needed rebuilt using this debug on feature. When i originally tried the solution it did not work. I deleted the build directory, so that everything had to be rebuilt, and then it worked just like i wanted.