Java is a high level programming language.It was developed by Sun-Microsystems. It runs in Java Runtime Environment(JRE). Unlike php which is an interpreted language, Java is compiled and interpreted language both. The whole program is compiled initially and every statement is later executed line by line.
Java is machine independent. It runs on any operating system, whether it be Windows, Mac OS, linux, UNIX, but only as long as there is a Java Virtual Machine(JVM) installed on that machine.
Java is run on top of JVM. JVM is machine dependent but the language itself is not machine independent.