Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA- JRE/JDK/JVM (Platform Independency)

Tags:

java

Java is a platform independent language. But, JVM is machine dependent. So, my question is: Which parts of java are platform independent? JRE, JDK or JVM? Please Explain.

like image 563
Kartik Thakral Avatar asked Sep 15 '26 08:09

Kartik Thakral


2 Answers

JVM , JRE , JDK these are all the backbone of java language. Each components work separately . JDK and JRE physically exists but JVM is an abstract machine that means it has not physically exists.

enter image description here

JVM

JVM (Java Virtual Machine) is a software. It is a specification that provides runtime environment in which java bytecode can be executed. It is not physically exists.

JVMs are not same for all hardware and software, for example for windows os JVM is different and for Linux JVM is different. JVM, JRE and JDK are platform dependent because configuration of each OS differs. But, Java is platform independent.

JRE

The Java Runtime Environment (JRE) is part of the Java Development Kit (JDK). It contains set of libraries and tools for developing java application. The Java Runtime Environment provides the minimum requirements for executing a Java application. It physically exists. It contains set of libraries + other files that JVM uses at runtime.

enter image description here

JDK

The Java Development Kit (JDK) is primary components. It physically exists. It is collection of programming tools and JRE, JVM.

enter image description here

like image 106
Mohsen_Fatemi Avatar answered Sep 16 '26 22:09

Mohsen_Fatemi


All 3 are platform dependent.

  1. JVM -> platform dependent.
  2. JRE -> consists of JVM and some other things. Since it include JVM, it is platform dependent.
  3. JDK -> consists of JRE, compiler and some other things. Since it includes JRE which in turn includes JVM, it is platform dependent.

The java code before and after compilation is platform independant. You can compile on windows and run the byte code on unix using Unix's jvm.

like image 35
VHS Avatar answered Sep 16 '26 20:09

VHS