I'm creating a jar using ant, but when I try to run one of my classes in ant - it does nothing. On Inspection of the jar it creates, the paths.properties I need to run the class has an empty path in the folder when I open it with winzip - anyone come across this before?
I have a
<target name="build" depends="init">
<javac srcdir="$(src.dir)" destdir="$(build.dir)" />
<target name="dist" depends="build">
<jar jarfile="$(dist.dir)/test.jar" basedir="$(build.dir)" />
<target name="runClass" depends="dist">
<java classname="com.test.Test" fork="yes" >
I can run the class Test fine from the cmd line fine, but it contains a paths.properties loaded up in it whose path isn't in the jar. When I open the jar with winzip it looks like:
I presume that's why it's not working in ant??
I don't get the question. Are you asking why Ant puts that properties file in the root directory of the jar? Should Ant be putting it somewhere else in the jar, and if so, where? Or are you just avoiding the question about why your code isn't written to look for the properties file there?
I'm not avoiding it - I'm trying to understand how to make it work properly!
My class Test is in the the package com.test and when I run the ant build Test.class goes to: build/com/test and the jar goes to the /dist directory.
I can use a copy function that will put the properties file in the build folder but the class still won't run through ant.
Am I missing something simple here? is it easy to get working?
I didnt get your question completely but as far as I understood, your Test.java class is present in the package com.test and you have a properties file which your Test.java access. So in-order to get your Test running successful your properties file path has to used correctly in your code and this properties file should also be present in the class path.
Once you solve these issues it will definately run.
I hope this helps.
Amit Singh Rathore