1.Compile the Files which should be added.

javac Test.java

Incase you are working in eclipse the same thing can be seen under the bin directory in the Navigator tab.you need to navigate to the folder to access the class files.

2.Manifest.txt
Incase if you are going to run the jar file the main class which should be called should be added to JAR file as meta-data through META-DATA/MANIFEST.There should be a Carriage Return Empty line in Manifest.txt to get read properly

Manifest.txt

Main-Class: com.mugil.util.Test

3.Create JAR file using the Below command

jar cfm Test.jar manifest.txt com/mugil/util/*

The Above command should be executed from bin directory in our case

* specifies the list of all files in that folder

4.To Run this JAR file

 java -jar Test.jar

When you run the Created Jar file it should be exactly placed in the folder from where the com folder starts.

jar cfm Test.jar manifest.txt com/mugil/util/*

The letters “m” and “f” must appear in the same order that “manifest” and “jarfile” appear.

Comments are closed.