Simple How-To for JAVA / JAR Files
After creating your Program.java
code file ... do the following...
Compile the program (which checks for errors)
javac Program.java
If the program compiled correctly, you can now run it...
java Program
Now, we need want to put it in a JAR file. First, create a
manifest.txt. Inside this file should be the following...
Main-Class: Program <carriage return>
After creating the manifest.txt, we can create the JAR file... use the
following syntax
jar cvmf manifest.txt Project.jar
*.java *.class
Note : c means create, v means verbose, m means expect
a manifest
file, and f means expect a jar filename.
Note : It is important to include all CLASS files (object
files) and all JAVA files (source code files) in the JAR file.
To test your jar file, try running your program directly from the jar
java -jar Project.jar
It is very important that you test your JAR
file to make sure it executes BEFORE you submit it. A problem with JAR file
execution is usually related to the manifest file. If you receive an error
while trying to run your JAR file, delete your manifest file, recreate it,
recreate the JAR, and test it again.
This concludes the simple JAVA/JAR tutorial......