How to Create a JAR file in Linux

Create a Jar File

Created 3 sample files as file1.txt file2.txt and file3.txt
-bash-4.1$ ls
file1.txt file2.txt file3.txt
-bash-4.1$ jar -cvf test.jar *
added manifest
adding: file1.txt(in = 5) (out= 7)(deflated -40%)
adding: file2.txt(in = 5) (out= 7)(deflated -40%)
adding: file3.txt(in = 5) (out= 7)(deflated -40%)
-bash-4.1$ ls
file1.txt file2.txt file3.txt test.jar

Unjar a Jar File

I used the Jar that is created above:
-bash-4.1$ ls
test.jar
-bash-4.1$ jar -xvf test.jar
created: META-INF/
inflated: META-INF/MANIFEST.MF
inflated: file1.txt
inflated: file2.txt
inflated: file3.txt
-bash-4.1$ ls
file1.txt file2.txt file3.txt META-INF test.jar
-bash-4.1$

The Author

Ramesh Kunamaneni (RK)

Greetings!! This is Ramesh Kunamaneni (RK), I have a decade experience in IT and worked for various MNCs. I am happy to share my knowledge in this blog especially on Java, Groovy, Python, DevOps, Agile Methodology, Banking and Payments Domain. Please do watch this space for more interesting articles and updates!!

Leave a Reply