Pin It

Java Tools and Utilities for Java Programming Language

Java Tools and Editors
The Java SDK (Software Development Kit) comes with various utilities which helps programmer to work with Java platform efficiently. Java SDK comes with set of such powerful tools. Let us look into some of widely used tools or utilities one by one :

1.    javac – the java compiler

The javac tool is most widely used tool in Java. It provides compilation power to Java. It basically reads program containing classes and interfaces, compiles them to Java bytecodes. These bytecodes are java .class files. Let us look into the syntax of this command-line tool :

Syntax:
javac [options] [source_files] [@list_files] 

where,
options: Command-line options.
source_files: Source files to be compiled.
@list_files: A file containing a list of source file to be compiled.

Let us look into few examples:

1.    javac TestClass.java
This command  compiles TestClass.java into bytecodes named as TestClass.class .

2.    javac @list_files
This command compiles all java source files listed in the file called as list_files.
     
 2.   java – the application launcher
The java tool launches a Java application. It starts Java Runtime Environment, loads the specified .class file and invokes main method in the class.

Syntax:
java [options] [class_name] [argument list]
java [options] –jar JarName.jar [argument list]

After the option this tool contains name of the class file to be execute, which has the main method. If we use –jar option than we need to specify jar name containing all the classes and resource files. The tool searches main method class in the jar by reading manifest file.
 Let us look into few examples:

1. java TestClass
This command executes TestClass.class file by calling main method in it.

2. java –jar JarName.jar
This command launch main method of file listed in jars manifest file.

3. jdb – the java debugger
The Java Debugger tool jdb is used to help developer to find and fix bugs in java programs.

Syntax:
jdb [options] [class_name] [arguments]

Let us look into few examples:

1. jdb TestClass
This command executes TestClass.class and help programmer to debug the code. 

4. javap – Disassembling classes
The javap tool allows you to query any class and find out list of methods and constants or find out commands executed by the underlying JVM.

Syntax:
javap [options] [class_name]

 Let us look into few examples:

 1. javap java.lang.String
This command list all the methods and class members of String class. 

5. javah – Header file generator
This tool connects Java programs to C and C++ programs. It is used when Java wants to use legacy libraries or Java can’t do something because of platform needs. javah generates C header and source files that are needed to implement native methods. The generated header and source files are used by C programs to reference an object’s instance variables from native source code.

6. jar – the java archive manager
The jar tool is a java application that combines multiple files into a single JAR archive file. jar is general purpose archiving and compression tool, based on ZIP compression format. jar allows packaging of all files related to java applets or applications into single archive.

Syntax:
jar [options] [manifest] [input-files]

Let us look into few examples:
jar –cf JarName TestClass1.class TestClass2.class


Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot