Sunday 21 April 2013

What is a JAR file in Java


What is a JAR file in Java.

JAR file is the compressed file format. You can store many files in a JAR file. JAR stands for the Java Archive. This file format is used to distribute a set of java classes. This file helps you to reduce the file size and collect many file in one by compressing files. Downloading the files are become completed in very short duration of time because of reducing the file size. You can make the jar file executable by collecting many class file of your java application in it. The jar file can execute from the javaw (Java Web Start).
The JAR file format is based on the popular ZIP file format. Usually these file format is not only used for archiving and distribution the files, these are also used for implementing various libraries, components and plug-ins in java applications. Compiler and JVMs (Java Virtual Machine) can understand and implement these formats for java application.
For mentioning the product information like vendor name, product version, date of creation of the product and many other things related to the product are mentioned in the manifest file. Such type of files are special which are mentioned in the jar file for making it executable for the application. This file format is to be used for collecting auxiliary files associated with the components.

To perform basic operations for the jar file there has to be used the Java Archive Tool (jar tool). It is provided by the jdk (Java Development Kit). Following are some jar command which are invoked by the jar tool:
FunctionsCommand
creation a jar file
viewing contents of a jar file
viewing contents with detail of a jar file
extract all the files of a jar file
extract specific files from the jar file
update jar files
running a executable packaged jar file
jar cf jar-file-name file-name(s)_or_directory-name
jar tf jar-file-name
jar tvf jar-file-name
jar xf jar-file-name
jar xf jar-file-name file-name(s)_from_jar-file
jar uf jar-file-name file-name(s)_from_jar-file
java -jar jar-file-name

What Is Javadoc?


What Is Javadoc?

Javadoc is a program shipped with JDK that you can use to run over your source code to produce documentation of your classes in the same type of HTML files that Sun Microsystems has used for its Java API documentation. To use javadoc on your source code, you have to tag your code with a certain type of comment formats. A simple example of Javadoc comments looks like this:
 
/** 
* Class MyButton implements java.io.Serailizable,
extends java.awt.Button 
*/ 
public class MyButton 
{ 
/** 
* Does nothing interesting 
* 
* @param image the image to show on button 
* @param label text to show on button 
*/ 
public MyButton(String label, Image image) 
{ 
//code here 
} 
//rest of class here 
} 
Javadoc comments start with /**, end with */, and, in-between, use tags such as @param, @return, and @exception to describe the workings of a method.
Extracted comments are processed into a set of HTML files for later perusal by a web browser. Using Javadoc, you can view the class hierarchy, an index of all methods and fields, and the details of each class.
The nice thing about Javadoc comments is that you can embed HTML tags to format your text. For example:
 
/** 
* <B>The Use Of This Class is Prohibited By Law.</B> 
*/ 
will make "The Use Of This Class is Prohibited By Law." appear in bold.