×
☰ See All Chapters

What is JDK JRE and JVM in Java

Java Development Kit (JDK)

The Java Development Kit (JDK) is a software development environment used for developing Java applications. This is a package which includes the Java Runtime Environment (JRE), an interpreter/loader (java virtual machine), a compiler (javac), binary (exe) files, libraries, source code, documentation generator (javadoc) and other tools needed in Java development.

The Java Development Kit comes with a collection of tools that are used for developing and running Java programs. They include:

appletviewer

Enables us to run Java applets (without actually using a Java-compatible browser).

javac

The Java compiler, which translates Java source code to bytecode files that the interpreter can understand.

java

Java interpreter, which runs applets and applications by reading and interpreting bytecode files.

javap

Java disassembler, which enables us to convert bytecode files into a program description

javah

Produces header files for use with native methods.

javadoc

Creates HTML-format documentation from Java source code files.

jdb

Java debugger, which helps us to find errors in our programs.

Folder organization when JDK 1.9 (java Development kit) is installed to Windows OS

what-is-jdk-jre-and-jvm-in-java-0
 

Java Virtual Machine

When java file is compiled, output of java compiler (javac.exe in windows) is a bytecode (.calss file), but not native machine code. This bytecode is interpreted by virtual machine (not by real computer) as real computer interprets .exe files in C/C++.  Such a virtual machine is called as Java Virtual Machine (JVM).

what-is-jdk-jre-and-jvm-in-java-1
 

javac and java are the tools to execute program.

Translating java program into Byte code makes it much easier to run a program in wide variety of platforms/Environments, because only JVM need to be implemented. Once bytecode is ready, we can run it in windows, Linux, calculator, mobile, watch etc.., but one thing is all environments require just JVM. Details of JVM differ from environment to environment. (Platform to Platform)

what-is-jdk-jre-and-jvm-in-java-2
 

 

JVM can also be called as java bytecode interpreter, but actually java tool (java.exe in Windows OS) is an interpreter, which implements/simulates JVM. JVM then starts interpreting the bytecode.

When Java was still a new language, it was criticized for being slow: Since Java bytecode was executed by an interpreter, it seemed that Java bytecode programs could never run as quickly as programs compiled into native machine language (that is, the actual machine language of the computer on which the program is running). However, this problem has been largely overcome by the use of just-in-time compilers (JIT) for executing Java bytecode.

JIT is a part of JVM. A just-in-time compiler translates Java bytecode into native machine language. It does this while it is executing the program. Just as for a normal interpreter, the input to a just-in-time compiler is a Java bytecode program, and its task is to execute that program.

It is important to understand that it is not practical to compile an entire Java program into executable code all at once, because Java performs various run-time checks that can be done only at run time. Instead, a JIT compiler compiles code as it is needed, during execution. Furthermore, not all sequences of bytecode are compiled—only those that will benefit from compilation. The remaining code is simply interpreted. The translated parts of the program can then be executed much more quickly than they could be interpreted. Since a given part of a program is often executed many times as the program runs, a just-in-time compiler can significantly speed up the overall execution time.

Even though dynamic compilation is applied to bytecode, the portability and safety features still apply, because the JVM is still in charge of the execution environment.

JRE

JRE is an acronym for Java Runtime Environment. JRE comes along with JDK. This JRE is enough to execute java programs (to run class files). Complete JDK is not required to execute java programs.

The basic development system for Java programming is usually referred to as the JDK (Java Development Kit). It is a part of Java SE, the Java “Standard Edition”. Java SE comes in two versions, a Development Kit version (the JDK) and a Runtime Environment version (the JRE). The Runtime can be used to run Java programs, but it does not allow compiling your Java programs. The Development Kit includes the Runtime and compiler both.

Java Class Library (JCL)

The Java Class Library is a set of standard basic libraries like java.lang package, java.util package that is available to any application running on the JVM. As of version 8 of Java, there were more than 4 thousand classes available to the applications running on the JVM. The Java Standard Library (or API) includes hundreds of classes and methods grouped into several functional packages. Most commonly used packages are:

  1. Language Support Package (java.lang): A collection of classes and methods required for implementing basic features of Java. 

  2. Utilities Package (java.util): A collection of classes to provide utility functions such as date and time functions. 

  3. Input/Output Package (java.io): A collection of classes required for input/output manipulation. 

  4. Networking Package (java.net): A collection of classes for communicating with other computers via Internet 

  5. AWT Package (java.awt): The Abstract Window Tool Kit package contains classes that implements platform-independent graphical user interface. 

  6. Applet Package (java.applet): This includes a set of classes that allows us to create Java applets. The use of these library classes will become evident when we start developing Java programs. 

 


All Chapters
Author