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.
3 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.
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.
JDK
The Java Development Kit (JDK) is primary components. It physically exists. It is collection of programming tools and JRE, JVM.
1 Comment
All 3 are platform dependent.
- JVM -> platform dependent.
- JRE -> consists of JVM and some other things. Since it include JVM, it is platform dependent.
- 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.
Comments
JDK and JRE ---> Platform dependent, these are specific to different system. JVM ---> Platform independent, because JVM is specifications for JRE. It means JVM has some set of rules and JRE is giving the implementation to it. So, JRE is physical implementation of JVM.
Ex- Bank has some specific rules and SBI, BOI and UCO are the implementation for the Bank. Here in this case BANK is JVM and SBI, BOI and UCO are JRE.


