不能启动用Ant构建的jar文件



我在eclipse中有一个项目,它使用ant来编译类文件和引用的jar。使用eclipse中默认java构建器生成的类文件生成的jar文件可以正常工作,但是当使用ant编译源文件然后对结果进行jar处理时,在目标构建上执行java -jar时会出现错误"错误:在尝试打开文件.......jar时发生意外错误"。有人知道我做错了什么吗?下面是构建XML内容。下面是我传递给ant

的参数

-DInTouchV.SrcPath = $ {InTouchV。SrcPath} -DInTouchV。DropPath = $ {workspace_loc:/InTouchVTransferService/dist}

<project default="create_run_jar" name="Create Runnable Jar for Project InTouchVTransferService">
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--ANT 1.7 is required                                        -->
<property name="Version" value="1.3"></property> 
<tstamp>
    <format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<target name="Compile_Source">
    <javac srcdir="${InTouchV.SrcPath}/InTouchVTransferService/src"
                     destdir="${InTouchV.SrcPath}/InTouchVTransferService/bin"
                     classpath="${InTouchV.SrcPath}/lib/AtomClasses.jar"
                     debug="on"
                    includeantruntime="yes"
                    /> 
</target>
<target name="create_run_jar">
    <mkdir dir="${InTouchV.SrcPath}/InTouchVTransferService/bin"/>     
    <jar destfile="${InTouchV.DropPath}/InTouchVTransferClient.jar" filesetmanifest="mergewithoutmain">
        <manifest>
            <attribute name="Main-Class" value="com.emdat.inTouchV.main.Main"/>
            <attribute name="Class-Path" value="."/>
            <section name="common">
                <attribute name="Build-Version" value="${Version}"/>
                <attribute name="Build-Date" value="${TODAY}"/>
                <attribute name="Built-By" value="${user.name}"/>
                <attribute name="JVM Version" value="${java.runtime.name} - ${java.runtime.version}" />
            </section>
        </manifest>
        <fileset dir="${InTouchV.SrcPath}/InTouchVTransferService/bin"/>
        <zipfileset excludes="META-INF/*.SF" src="${InTouchV.SrcPath}/lib/AtomClasses.jar"/>
    </jar>
    <touch file="${InTouchV.DropPath}/Version.txt" />
    <echo file="${InTouchV.DropPath}/Version.txt">${Version}</echo>
</target>
</project>

发现问题,属性"JVM版本"包含一个空格。删除空格后,jar文件执行正确。老实说,我说不出为什么eclipse + ant jar的默认java构建器可以处理这个空间,而ant build + ant jar却不能。至少是固定的:D

相关内容

  • 没有找到相关文章

最新更新