O'Reilly logo

Java™ Phrasebook by Timothy Fisher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running a Program from a JAR File

java –jar Scorebook.jar

Using the java command-line executable, you can execute a Java application that is packaged in a JAR file. To do this, you use the –jar switch when running the java command. You must also specify the name of the JAR file that contains the application you want to execute.

You must specify the class containing the main() method that you want to execute in a manifest file. For example, to execute the com.timothyfisher.Scorebook class, you would use a manifest file with the following contents:

Manifest-Version: 1.2
Main-Class: com.timothyfisher.Scorebook
Created-By: 1.4 (Sun Microsystems Inc.)

The manifest file is placed in the JAR file along with your classes.

This functionality allows Java ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required