Steps to create an executable JAR archive (System must have JDK installed)

Researched By Robert Hoffman


Step 1
To simplify your task, put all files in the same directory. (if not you must specify paths to all files)

Step 2
Create a manifest file. Create a file with the .txt extention. 

Use the following EXACT syntax:

Main-Class: MyJavaProgram (note – need carriage return after this line)

Step 3
Assuming your file is called My.txt, on the command line type:

>jar cvmf My.txt MyJavaProgram.jar MyJavaProgram.class 

c – create a jar file
v – verbose
m – include manifest file
f – file output

To run, click on the jar file or from the command line type java –jar MyJavaProgram.jar

You can add source (or any other files) by tacking them onto the jar command.

>jar cvmf My.txt MyJavaProgram.jar MyJavaProgram.class MyJavaProgram.java