Execute a jar file using Ant -
I am trying to create a runner jar file from java classes from ant. Java classes use external jars. When I implement build.xml, exception is not found while running its display class Java program. Its collection is okay.
Part of my source code:
& lt; Path id = "project-libpath" & gt; & Lt; Fileset dir = "$ {lib.dir}" & gt; & Lt; Include name = "* .jar" /> & Lt; / Fileset & gt; & Lt; / Path & gt; & Lt; Path id = "project-classpath" & gt; & Lt; Fileset dir = "C: / xmldecode / lib" & gt; & Lt; Include name = "* .jar" /> & Lt; / Fileset & gt; & Lt; / Path & gt; & Lt; Target name = "compilation" dependent = "ready" & gt; & Lt; Javac srcdir = "$ {src.dir}" destdir = "$ {classes.dir}" & gt; & Lt; Classpath refid = "project-classpath" /> & Lt; / Javac & gt; & Lt; / Target & gt; & Lt; Target name = "jar" dependent = "compilation" & gt; & Lt; Copy todir = "$ {classes.dir}" & gt; & Lt; Fileset dir = "C: / xmldecode / lib" /> & Lt; / Copy & gt; & Lt; Pathconvert property = "mf.classpath" pathsep = ";" & Gt; & Lt; Path Refied = "Project-ClassPath" /> & Lt; Flataman / & gt; & Lt; / Pathconvert & gt; & Lt; Jar destfile = "$ {jar.dir} / $ {ant.project.name} .jar" based on "=" $ {classes.dir} "& gt; & lt; manifest & gt; & lt; attribute name = "Main-class" value = "$ {main-class}" /> & gt; & manifest; & lt; / manifest & Gt; & lt; / Jar & gt; & lt; / target & gt; Target name = "run" dependent = "jar" & gt; java jar = "$ {jar.dir} / $" {Ent. Project.name} .jar "fork =" true ">
Your problem is that the manifest classpath entries ";" character. I think the following:
< / Pre>
Can I suggest using the new ANT Task?
& lt; manifestclasspath property = "mf.classpath" jarfile = "$ {jar.dir} / $ {Ant.project.name} .jar "& gt; & Lt; Classpath refid = "project-classpath" /> & Lt; / Manifestclasspath & gt;
This powerful method will determine the path relative to the location of the jar, for example if the dependence of the jar is located in a Libre directory
Comments
Post a Comment