Return to Course Content Home

Making an Executable Jar

Okay, the bulk of this example is from https://netbeans.org/kb/articles/javase-deploy.html

I wanted to include some screen shots to make it a little more helpful.

First start with your working project. I have a really simple "JarDemo" project I created for this example, but use one of yours if you are walking through this.

Initial Project

Next, you need to set the project's main class. This is so the Jar file can create the necessary information into its manifest file. To do so, right click on the project Name and select "Properties", then select the "Run" category.

Main Class Property

Click OK to close out the window.

For our class use, this should do it! If you were building a more complex jar, you might need to select the Libraries category and include any libraries your application needs bundled.

Now, if you click on the "Build Project" icon at the top of the window...

Build Button

You will build the jar file. Ah, but where is it? Click on the "Files" view of your project and you should now see a "dist" folder. If you open it up, you will see the JarDemo.jar file.

Jar location

You can run the jar file at this point either from the command line

java -jar JarDemo.jar

Or if you are in Windows you can just double-click the jar file and it will run from there.