应用同样的方法
我已经编写了以下ant目标:
<target name="approval_request_parser_compile">
<taskdef resource="genjar.properties" classpath="GenJar.jar"/>
<genjar jarfile="prod/lib/approvalRequestParser.jar">
<class>
<fileset dir=".">
<include name="com.bet.Check.class"/>
<include name="com.bet.Approve.class"/>
<include name="com.bet.CheckText.class"/>
<include name="com.bet.Request.class"/>
<include name="com.bet.ApprovalRequestParser.class"/> #contains the main method
</fileset>
</class>
<classpath>
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<pathelement path="."/>
</classpath>
</genjar>
</target>
jar创建成功,但是当我进入/prod/lib并输入:
java -jar approvalRequestParser.jar
此错误被抛出:
no main manifest attribute, in approvalRequestParser.jar
任何想法?
我不使用genjar
,但您需要创建清单文件,参见下面的示例
<target name="buildJAR" depends="compile">
<tstamp>
<format property="BUILD.TSTAMP" pattern="MMMM dd yyyy hh:mm:ss" locale="en"/>
</tstamp>
<buildnumber file="build.number"/>
<mkdir dir="classes/META-INF"/>
<echo file="classes/META-INF/version.txt">Version: ${VERSION} (build #: ${build.number}, ${BUILD.TSTAMP})</echo>
<manifest file="classes/META-INF/MANIFEST.MF">
<attribute name="Specification-Title" value="ANY TEXT CAN GO HERE"/>
<attribute name="Specification-Version" value="${VERSION}"/>
<attribute name="Specification-Vendor" value="COMPANY NAME"/>
<attribute name="Implementation-Title" value="WHAT CODE DOES"/>
<attribute name="Implementation-Version" value="${VERSION} (build #: ${build.number}, ${BUILD.TSTAMP})"/>
<attribute name="Implementation-Vendor" value="WHO DOES IT"/>
</manifest>
<jar destfile="JAR FILE" basedir="classes"
includes="${CORE_CODE}" manifest="classes/META-INF/MANIFEST.MF"/>
</target>
我认为你可以对genjar task