Creating a JAR file using Command Prompt

Step 1
Compile your Java Code

Step 2
Create a manifest file like the one below

Main-Class: (Your Class name which has the main method)

Double press "enter" So that you have 2 empty lines after typing the above. (Save with extension .txt not .mf)

Step 3
run the following command on cmd

jar cfm "Name You want for your JAR file".jar "name of mainfest".txt "name of all classes, or you can use '*' ".class (eg: jar cfm MyProgram.jar manifest.txt *.class)

Press enter
Now a JAR File will be created in the current directory

Step 4
run your jar file by using the following command

java -jar "JAR Name".jar

Comments

Popular posts from this blog

The Story of Adam and Eve