Explain the purpose of jar file - Java

Explain the purpose of jar file. Can you explain how to create a jar file in java.

A Jar file contains mostly .class files and optionally other files like sound files, image files for Java applications, gathered into a single file in the compressed format. The JDK consists of all java class libraries are available as jar files. In an enterprise a Java application can be started with a Jar file.

A jar file can be created from the command line / console window by using the ‘jar’ command.

Example:
jar –cvf inventory.jar *.class

In the above example, all the .class files are compressed and stored in the jar file ‘inventory.jar’. Now, the inventory.jar is a class library for inventory operations of an enterprise. The ‘c’ stands for create, ‘v’ stands for verbose, means to show details while creating the file and ‘f’ stands for the file followed by it.
Difference between String s="hello"; and String s=new String("hello"); in Java
The statement String s = “hello” is initialized to s and creates a single interned object....
Java vs. Javascript
The differences of Java and Java Script are: - Java can stand on its own where as Java Script mandatorily be placed within an HTML document.....
Explain upcasting and downcasting in Java.
Upcasting: Java permits an object of a sub class can be referred by its super class. It is done automatically.....
Post your comment