Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用ant和genJar创建一个可运行的jar_Java_Ant_Jar_Executable Jar - Fatal编程技术网

Java 使用ant和genJar创建一个可运行的jar

Java 使用ant和genJar创建一个可运行的jar,java,ant,jar,executable-jar,Java,Ant,Jar,Executable Jar,我已经编写了以下ant目标: <target name="approval_request_parser_compile"> <taskdef resource="genjar.properties" classpath="GenJar.jar"/> <genjar jarfile="prod/lib/approvalRequestParser.jar"> <class>

我已经编写了以下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>
出现以下错误:

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>

版本:${Version}(内部版本:${build.number},${build.TSTAMP})

我认为您可以对genjar任务应用相同的方法,我没有使用
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>

版本:${Version}(内部版本:${build.number},${build.TSTAMP})
我认为您可以将同样的方法应用于genjar任务