我正在尝试使用 ant 来构建我的 jar 及其所有依赖项,但是Error: Could not find or load main class main.SteamduckBot
当我尝试使用java -jar ircbot.jar
命令运行 jar 时不断得到。
这是我的 build.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project name="ircbot" default="jar">
<!-- Name of the output .jar file -->
<property name="jar.name" value="ircbot.jar" />
<!-- Base directory for distribution target -->
<property name="deploy.home" value="." />
<!-- Base directory for compilation targets -->
<property name="build.home" value="." />
<!-- Main class -->
<property name="main.class" value="main.SteamduckBot" />
<!-- The base directory for all libraries (jar) files -->
<property name="lib.home" value="lib" />
<target name="jar" description="Create jar and MANIFEST.MF">
<pathconvert property="libs.project" pathsep=" ">
<mapper>
<chainedmapper>
<!-- remove absolute path -->
<flattenmapper />
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*" />
</chainedmapper>
</mapper>
<path>
<!-- lib.home contains all jar files,
in several subdirectories -->
<fileset dir="${lib.home}">
<include name="**/*.jar" />
</fileset>
</path>
</pathconvert>
<!-- create the jar -->
<jar jarfile="${deploy.home}/${jar.name}" basedir="${build.home}">
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Main-Class" value="${main.class}" />
<!-- Finally, use the generated libs path -->
<attribute name="Class-Path" value="${libs.project}" />
</manifest>
</jar>
</target>
</project>
Ant 构建得很好,但显然我一定做错了什么——我的错误在哪里?
这是我的项目的结构:
这是生成的 jar 的内容:这是 jar 的内容:http: //pastebin.com/iYQGsutE