Why is Java so Popular?

Two main reasons for popularity of Java are

1. Platform Independence
2. Object Oriented Language

On compiling a java file the output is a class file - which contains bytecode (instruction set of the JVM). JVM converts bytecode to executable instructions. The executable instructions are different in different operating systems. So, there are different JVM's for different operating systems. A JVM for windows is different from a JVM for mac.However, both the JVM's understand the bytecode and convert it to the executable code for the respective operating system.