java – Ant包含外部.jar
发布时间:2020-05-25 13:47:49 所属栏目:Java 来源:互联网
导读:我想在我的 java项目中包含外部jar.我正在使用蚂蚁.外部.jar位于文件夹lib中.我的build.xml看起来像这样: ?xml version=1.0 encoding=UTF-8?project path id=classpath fileset dir=lib includes=**/*.jar/ /path
|
我想在我的 java项目中包含外部jar.我正在使用蚂蚁.外部.jar位于文件夹lib中.我的build.xml看起来像这样: <?xml version="1.0" encoding="UTF-8"?>
<project>
<path id="classpath">
<fileset dir="lib" includes="**/*.jar"/>
</path>
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile">
<mkdir dir="build"/>
<javac srcdir="src" destdir="build" classpathref="classpath" />
</target>
<target name="jar">
<mkdir dir="trash"/>
<jar destfile="trash/test.jar" basedir="build">
<zipgroupfileset dir="lib" includes="**/*.jar"/>
<manifest>
<attribute name="Main-Class" value="com.Test"/>
</manifest>
</jar>
</target>
<target name="run">
<java jar="trash/test.jar" fork="true"/>
</target>
</project>
但它不起作用.当我想从外部.jar导入一些东西时,命令ant compile后出现错误:package com.something不存在..我应该编辑什么才能使它工作? 确切的错误: Compiling 23 source files to xy/build xy/src/com/Test.java:5: package com.thoughtworks.xstream does not exist import com.thoughtworks.xstream.*; ^ 1 error 解决方法你应该尝试没有包含属性:<fileset dir="lib" /> 在jar部分中,您包含以下类: <zipgroupfileset includes="*.jar" dir="lib"/> (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
