Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #10937
| From | www <xsli2@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | cannot create the runnable JAR file containing 3rd party JAR files |
| Date | 2011-12-21 12:03 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <12e4a109-e7da-410e-b16c-330884bf35d2@o14g2000vbo.googlegroups.com> (permalink) |
Dear All:
My directory structure is the following:
libs/externa/ containing a.jar, b.jar
libs/installed/ the generated runnable JAR file, "sample.jar", will
be here
src/ containing Java source files
build/ containing Java class files
The main class is x.y.z.MyMain
I have had a really hard time to create a runnable JAR file using
Ant(version 1.6.5). The JAR file, libs/installed/sample.jar, can be
generated. However, when I run it, the classes inside a.jar or b.jar
are not available and causes NullPointerException. When I un-tar
sample.jar, everything is there. I think manifest classpath is causing
the problem.
Following is my brief build.xml:
<filelist id="external.jars" dir="libs/external">
<file name="a.jar" />
<file name="b.jar" />
</filelist>
<path id="project.classpath">
<pathelement location="./build" />
<filelist refid="external.jars"/>
</path>
<target name="build" depends="init">
<javac debug="true" debuglevel="${debuglevel}" destdir="$
{build.dir}" source="${source}" target="${target}">
<src path="src" />
<classpath refid="project.classpath" />
</javac>
</target>
<target name="jar" depends="clean, build">
<pathconvert property="manifest.classpath" pathsep=" ">
<mapper>
<chainedmapper>
<!-- remove absolute path -->
<flattenmapper />
<!-- add libs/external prefix -->
<globmapper from="*" to="libs/external/*" />
</chainedmapper>
</mapper>
<path>
<filelist refid="external.jars"/>
</path>
</pathconvert>
<jar destfile="libs/installed/sample.jar" basedir="./build"
update="true">
<manifest>
<attribute name="Main-Class" value="x.y.z.MyMain" />
<attribute name="Class-Path" value="${manifest.classpath}"/>
</manifest>
<fileset dir="${externals.dir}"/>
</jar>
</target>
Thank you very much.
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
cannot create the runnable JAR file containing 3rd party JAR files www <xsli2@yahoo.com> - 2011-12-21 12:03 -0800
Re: cannot create the runnable JAR file containing 3rd party JAR files markspace <-@.> - 2011-12-21 14:23 -0800
Re: cannot create the runnable JAR file containing 3rd party JAR files www <xsli2@yahoo.com> - 2011-12-21 17:29 -0800
Re: cannot create the runnable JAR file containing 3rd party JAR files Roedy Green <see_website@mindprod.com.invalid> - 2011-12-22 02:22 -0800
csiph-web