Java Development Kit (JDK) is a bundle of software components that is used to develop Java based applications. JDK is an implementation of either of Java SE, Java EE or Java ME. Usually, learners start from JDK implementation of Java SE to learn core Java features, which is also known as Java SDK. JDK includes the JRE, set of API classes, Java compiler, Webstart and additional files needed to write Java applets and applications. Java Development Kit is a bundle of the following software components that are needed to develop Java based applications.
Java Compiler: Java compiler is javac tool located in /bin folder of the JDK installation directory. The javac tool (accessed using
javac command) reads class and interface definitions, written in the Java programming language, and compiles them into bytecode class files. It can also process annotations in Java source files and classes.
There are two ways to pass source code file names to
For a small number of source files, simply list the file names on the command line separated by blank space. For example:
D:\JavaPrograms>javac SelectionSortDemo.java SequentialSearchDemo.java
For a large number of source files, list the file names in a file, separated by blanks or line breaks. Then use the list file name on the
javac command line, preceded by an @ character. For an example, store three source file names SelectionSortDemo.java, SequentialSearchDemo.java, SystemOutPrintlnDemo.java in a file named source-file-list and then supply following command in order to compile the source code files stored in source-file-list.
Inner class definitions produce additional class files. These class files have names combining the inner and outer class names, such as
Java Interpreter: Java interpreter is used to interpret the
.class Java files that have been compiled by Java compiler (
javac). Java interpreter is accessed using
java command. The
java command starts a Java application. It does this by starting a Java runtime environment, loading a specified class, and calling that class's main method.
The method must be declared
public and static, it must not return any value, and it must accept a String array as a parameter. The method declaration has the following form:
public static void main(String args)
By default, the first argument without an option is the name of the class to be called. A fully qualified class name should be used. If the
-jar option is specified, then the first non-option argument is the name of a JAR file containing class and resource files for the application, with the startup class indicated by the Main-Class manifest header.
The Java runtime searches for the startup class, and other classes used, in three sets of locations: the bootstrap class path, the installed extensions, and the user class path.
Non-option arguments after the class name or JAR file name are passed to the main function.
Java Disassembler: The
javap command is the disassembly tool of JDK that disassembles one or more class files. Its output depends on the options used. If no options are used,
javap prints out the package,
public fields and methods of the classes passed to it. The
javap prints its output to stdout.
Java Header File Generator: Java Header File Generator (
javah command-line tool) 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. The
.h file contains a
struct definition whose layout parallels the layout of the corresponding class. The fields in the
struct correspond to instance variables in the class.
The name of the header file and the structure declared within it are derived from the name of the class. If the class passed to javah is inside a package, the package name is prepended to both the header file name and the structure name. Underscores (_) are used as name delimiters.
javah creates a header file for each class listed on the command line and puts the files in the current directory. Use the
-stubs option to create source files. Use the
-o option to concatenate the results for all listed classes into a single file.
The new native method interface, Java Native Interface (JNI), does not require header information or stub files. The
javah tool can still be used to generate native method function prototypes needed for JNI-style native methods. The
javah tool produces JNI-style output by default, and places the result in the
Java Documentation: Java Documentation helps to maintain code. The
javadoc tool comes as part of Java Development Kit that parses the declarations and documentation comments in a set of Java source files and produces a corresponding set of HTML pages describing (by default) the public and protected classes, nested classes (but not anonymous inner classes), interfaces, constructors, methods, and fields. You can use it to generate the API (Application Programming Interface) documentation or the implementation documentation for a set of source files.
You can run the
javadoc tool on entire packages, individual source files, or both. When documenting entire packages, you can either use
-subpackages for traversing recursively down from a top-level directory, or pass in an explicit list of package names. When documenting individual source files, you pass in a list of source (
.java) file names.
Java Debugger: The Java Debugger,
jdb, is a simple command-line debugger for Java classes. It is a demonstration of the Java Platform Debugger Architecture that provides inspection and debugging of a local or remote Java Virtual Machine.
Java Applet Viewer: This is used to view the Java applets. The
appletviewer command connects to the documents or resources designated by urls and displays each applet referenced by the documents in its own window. Note: if the documents referred to by urls do not reference any applets with the OBJECT, EMBED, or APPLET tag, then
appletviewer does nothing. For details on the HTML tags that
appletviewer supports, see AppletViewer Tags.
JRE is an implementation of the JVM which actually executes Java programs. It includes the JVM, core libraries and other additional components to run applications and applets written in Java. Java Runtime Environment is a must install on machine in order to execute pre compiled Java Programs. JRE is smaller than the JDK so it needs less disk space and it is so because JRE does not contain Java compiler and other software tools needed to develop Java programs.
|JRE (Java Runtime environment)||JDK (Java Development Kit)|
|JRE is an implementation of the Java Virtual Machine which actually executes Java programs.||JDK is a bundle of software that is used to develop Java based applications.|
|Java Runtime Environment is a plug-in needed for running Java programs.||Java Development Kit is needed for developing Java applications.|
|JRE is smaller than the JDK so it needs less disk space.||JDK needs more disk space as it contains the JRE along with various development tools.|
|JRE includes the JVM, Core libraries and other additional components to run applications and applets written in Java.||JDK includes the JRE, set of API classes, Java compiler, Webstart and additional files needed to write Java applets and applications.|
Java program execution uses a combination of compilation and interpretation. Programs written in Java are compiled into machine language, but it is a machine language for a computer that is, virtual and doesn't really exist. This so-called "virtual" computer is known as the Java virtual machine (JVM). The machine language for the Java virtual machine is called Java bytecode.
Java Virtual Machine is a program that runs pre compiled Java programs, which mean JVM executes
.class files (byte-code) and produces output. The JVM is written for each platform supported by Java included in the Java Runtime Environment (JRE). The Oracle JVM is written in the C programming language. There are many JVM implementations developed by different organizations. They may somewhat differ in performance, reliability, speed and so. They can too differ in implementation especially in those features where Java specification does not mention implementation details of the feature. Garbage collection is the nice example which is left on vendor's choice and Java specification does not provide any implementation details.
The Just-In-Time (JIT) compiler is a component of the Java Runtime Environment (JRE). It improves the performance of Java applications by compiling bytecodes to native machine code at run time. When a Java program is run JVM launched that interprets the byte code and provides result. At run time, the JVM loads the class files, determines the semantics of each individual bytecode, and performs the appropriate computation. In this process, the JIT compiler helps improve the performance of Java programs by compiling bytecodes into native machine code at run time.
The JIT compiler is enabled by default, and is activated when a Java method is called. The JIT compiler compiles the bytecodes of that method into native machine code, compiling it "just in time" to run. When a method has been compiled, the JVM calls the compiled code of that method directly instead of interpreting it. Theoretically, if compilation did not require processor time and memory usage, compiling every method could allow the speed of the Java program to approach that of a native application.
JIT compilation does require processor time and memory usage. When the JVM first starts up, thousands of methods are called. Compiling all of these methods can significantly affect startup time, even if the program eventually achieves very good peak performance.
In practice, methods are not compiled the first time they are called. For each method, the JVM maintains a call count, which is incremented every time the method is called. The JVM interprets a method until its call count exceeds a JIT compilation threshold. Therefore, often-used methods are compiled soon after the JVM has started, and less-used methods are compiled much later, or not at all. The JIT compilation threshold helps the JVM start quickly and still have improved performance. The threshold has been carefully selected to obtain an optimal balance between startup times and long term performance.
After a method is compiled, its call count is reset to zero and subsequent calls to the method continue to increment its count. When the call count of a method reaches a JIT recompilation threshold, the JIT compiler compiles it a second time, applying a larger selection of optimizations than on the previous compilation. This process is repeated until the maximum optimization level is reached. The busiest methods of a Java program are always optimized most aggressively, maximizing the performance benefits of using the JIT compiler. The JIT compiler can also measure operational data at run time, and use that data to improve the quality of further recompilations.
The JIT compiler can be disabled, in which case the entire Java program will be interpreted. Disabling the JIT compiler is not recommended except to diagnose or work around JIT compilation problems. Following figure demonstrates the JIT compile process pictorially.
In this tutorial commonly used Java acronyms like JDK, JRE, JVM, and JIT have been explained along with their differences. Hope you have enjoyed reading this tutorial, please do write us if you have any suggestion/comment or come across any error on this page. Thanks for reading!
Germany's spy agency says China is using the site to gather information on politicians.Bitcoin futures trading begins on CBOE exchange in ChicagoPosted on Monday December 11, 2017
Trading in futures contracts is a step towards legitimising the digital currency, its supporters say.Calls for Twitch to police 'sexual streaming'Posted on Saturday December 09, 2017
The game streaming site has been criticised for tolerating a growing number of 'sexual streamers'Courtesy BBC News