Compilation into bytecode is done using javac , the Java compiler. And the difference between the JDK (Java Development Kit) and the JRE (Java Runtime Environment) is that the JDK includes javac and the JRE does not.
Compilation in the form of a bytecode is a true compilation - the bytecode format is completely different from the original source . But the bytecode must be interpreted or compiled to work on most hardware systems. (Several experimental hardware systems have been built that can directly take the form of bytecode.)
On most systems, bytecodes begin to be interpreted (via, duh, the "Java interpreter", which is part of the JRE). As the code executes, the "hot" parts of the bytecode are compiled by the "compiler" exactly at the point in time (JITC is also part of the JRE), and then executed with the same efficiency as C ++ or another "directly compiled" language.
It should be noted that the bytecode format is very similar to the "intermediate language" formats used by many traditional "two-phase" / "optimizing" compilers. In this sense, javac is the first part of a traditional compiler.
source share