What is Java Platform & Components(JDK, JRE, JVM)?

 

What is Java Platform?

  • Java Platform is a collection of programs that help programmers to develop and run Java programming applications efficiently. 
  • It includes an execution engine, a compiler, and a set of libraries in it.
  • It is a set of computer software and specifications. 
  • James Gosling developed the Java platform at Sun Microsystems, and the Oracle Corporation later acquired it.
===================================================
Components







Java Development kit (JDK)

JDK is a software development environment used for making applets and Java applications. The full form of JDK is Java Development Kit. Java developers can use it on Windows, macOS, Solaris, and Linux. JDK helps them to code and run Java programs. It is possible to install more than one JDK version on the same computer.

Why use JDK?

Here are the main reasons for using JDK:

  • JDK contains tools required to write Java programs and JRE to execute them.
  • It includes a compiler, Java application launcher, Appletviewer, etc.
  • Compiler converts code written in Java into byte code.
  • Java application launcher opens a JRE, loads the necessary class, and executes its main method.


Java Virtual Machine (JVM):

Java Virtual Machine (JVM) is an engine that provides a runtime environment to drive the Java Code or applications. It converts Java bytecode into machine language. JVM is a part of the Java Run Environment (JRE). In other programming languages, the compiler produces machine code for a particular system. However, the Java compiler produces code for a Virtual Machine known as Java Virtual Machine.

Why JVM?

Here are the important reasons of using JVM:

  • JVM provides a platform-independent way of executing Java source code.
  • It has numerous libraries, tools, and frameworks.
  • Once you run a Java program, you can run on any platform and save lots of time.
  • JVM comes with JIT (Just-in-Time) compiler that converts Java source code into low-level machine language. Hence, it runs faster than a regular application.

How Java Virtual Machine works?

By using Java Virtual Machine, this problem can be solved. But how it works on different processors and O.S. Let’s understand this process step by step.

What is Java Platform?

Step 1) The code to display the addition of two numbers is System.out.println(1+2), and saved as a .java file.

Step 2) Using the java compiler the code is converted into an intermediate code called the bytecode. The output is a .class file.

Step 3) This code is not understood by any platform, but only a virtual platform called the Java Virtual Machine.

Step 4) This Virtual Machine resides in the RAM of your operating system. When the Virtual Machine is fed with this bytecode, it identifies the platform it is working on and converts the bytecode into the native machine code.



Java Runtime Environment (JRE)

JRE is a piece of software that is designed to run other software. It contains the class libraries, loader class, and JVM. In simple terms, if you want to run a Java program, you need JRE. If you are not a programmer, you don’t need to install JDK, but just JRE to run Java programs.

Why use JRE?

Here are the main reasons of using JRE:

  • JRE contains class libraries, JVM, and other supporting files. It does not include any tool for Java development like a debugger, compiler, etc.
  • It uses important package classes like math, swing, util, lang, awt, and runtime libraries.
  • If you have to run Java applets, then JRE must be installed in your system.