首页 > 编程语言 > 详细

netbeans 将项目打包生成单个可执行的 jar

时间:2015-07-13 13:31:32      阅读:358      评论:0      收藏:0      [点我收藏+]

原文:netbeans 打包生成 jar

技术分享

文件页里找到build.xml文件,打开在</project>前 加入以下代码保存之

 

    <target name="package-for-store" depends="jar">

        <!-- Change the value of this property to be the name of your JAR,
             minus the .jar extension. It should not have spaces.
             <property name="store.jar.name" value="MyJarName"/>
        -->
        <property name="store.jar.name" value="SwitchHexAndChinese"/>


        <!-- don‘t edit below this line -->

        <property name="store.dir" value="store"/>
        <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>

        <echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>

        <delete dir="${store.dir}"/>
        <mkdir dir="${store.dir}"/>

        <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
            <zipgroupfileset dir="dist" includes="*.jar"/>
            <zipgroupfileset dir="dist/lib" includes="*.jar"/>

            <manifest>
                <attribute name="Main-Class" value="${main.class}"/>
            </manifest>
        </jar>

        <zip destfile="${store.jar}">
            <zipfileset src="${store.dir}/temp_final.jar"
            excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
        </zip>

        <delete file="${store.dir}/temp_final.jar"/>

    </target>

  其中 <property name="store.jar.name" value="SwitchHexAndChinese"/> 中的value可以随意更改,这个就是jar包名

build.xml右键即可打包生成SwitchHexAndChinese.jar

技术分享

 

生成的文件

技术分享

 

netbeans 将项目打包生成单个可执行的 jar

原文:http://www.cnblogs.com/lonelyxmas/p/4642428.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!