Baxter
Baxter

Reputation: 5845

Export Jar File in NetBeans

I am looking for a way to export a .jar file in Netbeans. I know that when I clean/build it automagically puts everything in a .war file in the dist directory. However, in Eclipse you can select Export -> Export -> Java -> JAR file and click next and select only the resources you want to export and select a location to export the .jar file to. Is there any equivalent to this in Netbeans?

Upvotes: 1

Views: 1129

Answers (3)

Steven
Steven

Reputation: 51

If you know how to write Ant files, edit the build.xml and add a -post-dist target. Then the jar file will also be created when the war file gets created. Something like:

<target name="-post-dist" description="Create jar file.">
    <!-- Copy your files to a temp directory if necessary. -->
    <copy ...>
       ...
    </copy>

    <!-- 'basedir' should be the directory from which to jar the files -->
    <jar destfile="${dist.dir}/app.jar" basedir="${build.dir}/myjarfiles"/>
</target>

Upvotes: 0

Baxter
Baxter

Reputation: 5845

I ended up just building the project the usual way getting a .war file in the dist folder.
I then used a zip program called IZArc: http://www.izarc.org/ to open the .war and get out only what I needed to build the .jar. I then used IZArc again to create the .jar file.
If anyone knows of an easier way (preferably through Netbeans itself) please let me know.

Upvotes: 0

mandy
mandy

Reputation: 11

you can enable the "Build JAR after Compiling" property in Netbeans

File > Project Properties > Build > Packaging

Upvotes: 1

Related Questions