Java uses both compiler and interpreter to execute programs. Source code written in Java is compiled to generate byte code and then this byte code is interpreted to machine instructions for specific machine. The byte code generated by the compiler is not machine specific. It is generated for virtual machine that exists only inside the computer memory known as Java virtual machine (JVM).
Java compiler translates source code into byte code.
Java interpreter translates byte code into machine code.
Fig: Process of converting Java Program into Machine code.