蚂蚁,jar文件和类路径哦我 [英] ant, jar files, and Class-Path oh my

查看:130
本文介绍了蚂蚁,jar文件和类路径哦我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重新构建我的生成技术用于创建依赖于共同的第三方jar文件的Java jar文件。 (GlazedLists,阿帕奇共享,等等。)

I am trying to rearchitect my build technique for creating Java jar files which depend on common 3rd party jar files. (GlazedLists, Apache Commons, etc.)

我已经夹紧他们都到{的Java JRE目录} / lib / ext目录,这样他们就自动被JRE待观察,但导致像没有记住我需要分发某些jar文件的问题,所以我想了解更清晰。

I had been chucking them all into {Java JRE dir}/lib/ext so they would automatically be seen by the JRE, but that led to problems like not remembering that I need to distribute certain jar files, so I'd like to learn to be more explicit.

因此​​,我搬到他们都到C:\\申请\\ java的\\ COMMON \\,将它们添加到Eclipse构建路径,A和我的蚂蚁文件中定义的:

So I moved them all into c:\appl\java\common\, added them to the Eclipse build path, aand defined this in my ant file:

<path id="javac_classpath">
    <fileset dir="${libDir}">
        <include name="*.jar"/>
    </fileset>
    <fileset dir="c:/appl/java/common">
        <include name="*.jar"/>
    </fileset>
</path>

我有我的类路径清单头设置为。在我的 JAR 任务,但似乎并不即使我把有关的jar文件到同一个目录我的应用程序的jar文件的工作。我可以把他们手动一个接一个的Class-Path头,但我想知道,有没有更简单的方法来获得正确的Class-Path头设置?

I have my Class-Path manifest header set to "." in my jar task but that doesn't seem to work even if I put the relevant jar files into the same directory as my application jar file. I can add them all manually one-by-one to the Class-Path header, but I'm wondering, is there an easier way to get the Class-Path header setup properly?

推荐答案

这是你所需要的:

<path id="build-classpath">
    <fileset dir="${dist}/lib">
        <include name="*.jar"/>
    </fileset>
</path>
<manifestclasspath property="lib.list" jarfile="${dist}/lib/myprog.jar">
    <classpath refid="build-classpath"/>
</manifestclasspath>
<jar jarfile="${dist}/lib/myprog.jar"
     basedir="${build}"
     includes="com/my/prog/**" >
    <manifest>
        <attribute name="Main-Class" value="com.my.prog.MyProg"/>
        <attribute name="Class-Path" value="${lib.list}"/>
    </manifest>
</jar>

正如你很可能会看到,它假定你已经编译了Java类和它们输出到 $ {构建} 。它还假定您复制好jarfiles中以 $ {} DIST / lib目录

As you can probably see, it assumes you've compiled your Java classes and output them to ${build}. It also assumes you've copied your jarfiles to ${dist}/lib.

这篇关于蚂蚁,jar文件和类路径哦我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆