Saturday, 20 December 2014

What is javac, java, javap and javadoc commands in java ?

javac:

javac is command or tool which is used to compile java file.It also known as java compiler(javac).
It phisically exists in the system at java installed folder.

In my system its location is :  C:\Program Files\Java\jdk1.6.0_21\bin
Under this bin folder you can see as javac.exe  that  is javac compiler.

To compile any java file we use it as: javac (java file name).java

java:

java  is also a command or tool just like javac but it is used to run a java file.
It phisically exists in the system at java installed folder.

In my system its location is :  C:\Program Files\Java\jdk1.6.0_21\bin
Under this bin folder you can see as java.exe  that  is java tool.

To run any java file we use it as: java (java class name)

javap:

javap is also a command or tool(important).It is used to see the structure of any pre defined or
user defined class.(means to see how many methods, variables, constants,constructor etc in a class)
It phisically exists in the system at java installed folder.

In my system its location is :  C:\Program Files\Java\jdk1.6.0_21\bin
Under this bin folder you can see as javap.exe  that  is javap tool.

For Example:

If you want to see what is the structure of Object class or System class then follow below commands.

To use it type this command at cmd: javap  java.lang.Object
and then press enter button

Systex to run this command: javap full_package_name.Class_Name
i.e. javap java.lang.System

Note: By using command  this you can also see your owned creted class structure.

javadoc:

javadoc  is also a command or tool which is used to create API documents of usered defined class.
It is java documentation command.In the java file, we must use the documentation comment /**..... */ to post information for the class, method, constructor, fields etc.
It phisically exists in the system at java installed folder.

In my system its location is :  C:\Program Files\Java\jdk1.6.0_21\bin
Under this bin folder you can see as javadoc.exe  that  is java API documentation command.

For Example :

package com.vishwa;
/** This class is a user-defined class that contains one methods square.*/
public class Test{

/** The cube method prints cube of the given number */

public static void cube(int x)  {  
System.out.println(x*x);  
      }
}
If you want to make API documents of any usered defined(own) class then by using javadoc command you can make.

To use it type this command at cmd:  javadoc class_name.java  (as javadoc Test.java)

and then press enter button.Now you see at the same location where your this class_name java file is there at that place many .html files, .css and package-list  file created.

i.e. javadoc Test.java (here Test.java is a java file for which I want to make API documents)

Note: These are the main java tools or commands used mainly in java programming.

If any doubts about these tools or any concepts then please feel free to asked me.
You can comments on my post or asked any query  I will try my best to  clear your doubts.
And if any errors or suggestions please feel free to tell me.

No comments:

Post a Comment