Sei sulla pagina 1di 1

Use NetBeans IDE 6.

7 to Combine JAR Files Into a Single JAR File


1. Create Mars Rover Viewer project in Samples folder in NetBeans
2. Switch to Files tab, and open build.xml which is ANT script
3. Edit the file, add following text at the bottom of build.xml and before </project> tag

<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="MarsRoverViewer"/>

<!-- 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>

Note that you must change the following line in the Ant code above to match your particular project.

<property name="store.jar.name" value="MarsRoverViewer"/>

The property store.jar.name specifies the name of the JAR file that will be created in the store directory — change
the value to whatever name you like. When you done your coding, right click on the build.xml—>Run Target
—>Other Targets—>package-for-store

A folder called Store should appear in your project folder and the MarsRoverViewer.jar should sit in there
double click it and run!

Potrebbero piacerti anche