Creating and Handling JAR files

By: Reema sen Emailed: 1766 times Printed: 2515 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

A utility is used to generate a JAR file. Its syntax is shown here:

jar options files

Creating a JAR File

The following command creates a JAR file named Xyz.jar that contains all of the .class and .gif files in the current directory:

jar cf Xyz.jar *.class *.gif

If a manifest file such as Yxz.mf is available, it can be used with the following command:

jar cfm Xyz.jar Yxz.mf *.class *.gif

Tabulating the Contents of a JAR File

The following command lists the contents of Xyz.jar:

jar tf Xyz.jar

Extracting Files from a JAR File

The following command extracts the contents of Xyz.jar and places those files in the current directory:

jar xf Xyz.jar

Updating an Existing JAR File

The following command adds the file file1.class to Xyz.jar:

jar -uf Xyz.jar file1.class

Recursing Directories

The following command adds all files below directoryX to Xyz.jar:

jar -uf Xyz.jar -C directoryX *


Java Home | All Java Tutorials | Latest Java Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Reema sen
this keyword sample in Java
Using the DriverManager Class vs Using a DataSource Object for a connection
Steps to get a Free SSL certificate for your Tomcat
fgets(), fputs() - Line Input and Output - sample program in C
Address Arithmetic and pointers in C
Constants and escape sequences in C
Implementing Pure Virtual Functions in C++
strcat() and strncat() sample program in C++
paint() sample program to draw a line in J2ME
Creating and Handling JAR files
SequenceInputStream example program in Java
FilenameFilter - sample program in Java
Transient vs Volatile modifiers in Java
while (1) Loops in C++
Use of 'finally' in Java

More Tutorials in Java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Java File
Java String
Count number of vowels, consonants and digits in a String in Java
Reverse a number in Java
Student marks calculation program in Java
Handling Fractions in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java
Multiple Inheritance sample in Java
Java program using Method Overriding
Java program to check if user input is an even number

More Latest News
Most Viewed Articles (in Java )
A Serialization Example in Java
indexOf( ) and lastIndexOf( ) in Java
The java Buzzwords
Student marks calculation program in Java
Handling Fractions in Java
Calculate average sale of the week in Java
Write to a file in Java - Sample Program
How to create an array and method in JSP
How to use set, get basic and nested properties for Spring framework
Creating and Handling JAR files
A Tutorial on importing packages in Java
do-while - Iteration in java
Increment and Decrement Operator
Character Arrays
Update contents of a file within a jar file
Most Emailed Articles (in Java)
Converting a number into its equalant value in words in Java
java.lang.reflect package
Disadvantages of using Native methods in Java
What is UCS? What is ISO 10646?
Generating Your Key Pair example using keytool in Java
Operator Precedence in Java
PushbackReader sample program in Java
concat(), replace(), and trim() Strings in Java
instanceof sample program in Java
Use of - new - in Java
The Benefits of OOP
Increment and Decrement Operator
Characters in java
The continuing Revolution of java
Why java is important to the Internet