At the bottom of this page:
You will find something like this:
I just created a file called "mainClass", and typed the above, voila!
To create a JAR file having a manifest with the appropriate Main-Class header, you can use the Jar tool's m flag as described in the Modifying a Manifest section. You would first prepare a text file consisting of single line with the Main-Class header and value. For example, if your application was the single-class HelloWorld application, the entry point would of course be the HelloWorld class, and your text file would have this line:
Assuming your text file was in a file called mainClass, you could merge it into a JAR file's manifest with a command such as this:
jar cmf mainClass app.jar HelloWorld.class
With your JAR file prepared in this way, you can run the HelloWorld application from the command line:
java -jar app.jar