Java
Java is platform independent all you need to run java code is JVM. Java application is platform independent but JVM is not is has to be built for a particular OS.
As Java is object-oriented which means everything should be inside a class.
Java is W.O.R.A. i.e write once run anywhere.
How Java Works
In most of our machines, regardless of our OS, we have JVM installed which makes java platform independent, which runs java application.
JRE
JRE stands for Java Runtime Environment. JVM is part of JRE. JRE also contains lib that needs to run java code.