Java is platform independent.
Java program can be executed on any platform, without any modifications.
Platform = OS + Hardware (CPU , mother board , hw architecture).
JVM is where all java programs will be executed.
JVM full form is "Java Virtual Machine"
Generally all the java code will be running in "JVM" with the help of O.S kernel layer.
[Test.java] --compiler--> [Test.class](byte code) ---JVM---> Final machine code ---CPU--> output.
Below is the pictorial representation of how a java program gets compiled and executed:
Byte code generated by java compiler is not understood by CPU.
It is the responsibility of JVM to convert bytecode to final machine code, which your CPU understands.
In the above example you can run the same .class file(byte code) on any machine (windows, or linux) with out recompiling. That is possible with the help of JVM.
So, JVM plays a crucial role in making Java Platform Independent. With out JVM it is impossible to run .class file on different different platforms. This is the reason why java is Platform independent.
Your CPU will not understand .class files, but only JVM understands .class files.
So, Every architecture and OS will have its own JVM. (so JVM is platform dependent)
Note: Java is platform independent but JVM is platform dependent.
JRE = Java RunTime Environment.
An environment where, java program executes.
JRE = JVM + Run time libraries
JVM = Java Virtual Machine
A virtual machine, where java program executes.
JVM = JIT compiler + Garbage collector + byte code verifier + Memory Manager
JDK = Java Development Kit
A software used to write java programs, need for programmers.
JDK = libraries helpful to build java apps + java compailer + java executor
Note : For developing & writing java programs, programmer needs JDK software.
For clients to run the java program, they need JRE
Eclipse is an IDE (Integrated Development Environment), where programmer will write, test, debug the java program.