The Java bytecode comprising an application is commonly bundled and delivered in the form of a Java Archive (JAR) file.

Here I gonna start how to create JAR File

-open command

-go to ur files & folders destination and compile the java file then


for eg. [sourcecode=’c’]jar tvf final.jar[/sourcecode]

Output looks like this:


Using Bytecode contained with in a JAR file.

For informing the Java Virtual Machine that we want to use the bytecode of a JAR file, we use a code(command) option to set an environment variable called the classpath:

for eg.[sourcecode=’c’] java -cp final.jar A[/sourcecode]

Extracting Content of a JAR File

Here we can extract every files of jar file by the following command:

for eg.[sourcecode=’c’]
jar xvf final.jar A.class B.class[/sourcecode]

To extract everything from a JAR file, we’d type:

[sourcecode=’c’]jar xvf final.jar[/sourcecode]

Jarring Entire Directory Hierarchies

Here we are going to extract all the subfolder and all files of the folder in a single jar file.

for eg. [sourcecode=’c’]jar cvf new.jar “C:JavaProject”[/sourcecode]

//don’t forget to put quote for the folder directory