What Is JDK, JRE and JVM

the difference between JDK, JRE and JVM is important in Java. We are having overview of JVM .

JVM (Java Virtual Machine)

JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.
JVMs are available for many hardware and software platforms. JVM, JRE and JDK are platform dependent because configuration of each OS differs. But, Java is platform independent.

What is JVM

A specification where working of Java Virtual Machine is specified. But implementation provider is independent to choose the algorithm. Its implementation has been provided by Sun and other companies.
An implementation Its implementation is known as JRE (Java Runtime Environment).
Runtime Instance Whenever you write java command on the command prompt to run the java class, an instance of JVM is created.

What it does

The JVM performs following main tasks:
  • Loads code
  • Verifies code
  • Executes code
  • Provides runtime environment
  • JVM provides definitions for the:
  • Memory area
  • Class file format
  • Register set
  • Garbage-collected heap
  • Fatal error reporting etc.
  • JRE

    JRE is an acronym for Java Runtime Environment.It is used to provide runtime environment.It is the implementation of JVM. It physically exists. It contains set of libraries + other files that JVM uses at runtime.
    Implementation of JVMs are also actively released by other companies besides Sun Micro Systems.
    JRE stands for Java Runtime Environment which is used to provide an environment at run time. It is the cause of implementation of JVM (as discussed earlier). It contains set of supporting libraries in combination with core classes and various other files that are used by JVM at run time. JRE is a part of JDK (Java Development Toolkit) but can be downloaded separately.


    JDK (Java SE Development Kit) Includes a complete JRE (Java Runtime Environment) plus tools for developing, debugging, and monitoring Java applications. JDK is required to develop and run Java applications and applets.
    JDK is an acronym for Java Development Kit.It physically exists.It contains JRE + development tools.

    variable in java

    Variables are the identifier of the memory location, which used to save data temporary for later use in the program.

    Variable Definition in Java

    type variable_name;
    type variable_name, variable_name, variable_name;
       /* variable definition and initialization */
    int  width, height=5;
    char letter='C';
    float age, area;
    double d;
    /* actual initialization */
    width = 10;
    age = 26.5; 

    Rules of Declaring variables in Java

  • Variable name can consist of Capital letters A-Z, lowercase letters a-z, digits 0-9, and two special characters such as underscore and dollar Sign.
  • The first character must be a letter.
  • Blank spaces cannot be used in variable names.
  • Java keywords can not be used as variable names.
  • Variable names are case-sensitive.
  • Types of Variables in Java

    There are three types of variables in Java:
  • Local variables
  • Instance variables
  • Class/Static variables
  • Local variables
    A variable that is declared within the method that is called local variables.
    Instance variables
    A non static variable that is declared within the class but not in the method is called instance variable.
    Class/Static variables
    A variable that is declared with static keyword in a class but not in the method is called static or class variable.>
    class A {
    int amount = 100; //instance variable  
    static int pin = 2315; //static variable 
    public static void main(String[] args) {
    int age = 35; //local variable  
    public class Example {
    int salary; // Instance Variable
    public void show() {
    int value = 2; // Local variable
    value = value + 10;
    System.out.println("The Value is : " + value);
    salary = 10000;
    System.out.println("The salary is : " + salary);
    public static void main(String args[]) {
    Example eg = new Example();