Với câu hỏi này thì bạn phải trả lời là : Compile once and run everywhere (both)
Javac is Java Compiler – Compiles your Java code into Bytecode
JVM is Java Virtual Machine – Runs/ Interprets/ translates Bytecode into Native Machine Code -> cái cuối dùng JIT
3 bước chính
.java —JAVAC (Java compiler) - >.class— JVM[ Interpreter(Run time code )line by line + JIT(Just in time-Complier)block] ----> Mã máy
Bonus:
An interpreter takes instructions one-by-one and calls some function that represents this instruction in native code (that’s what is mean by interpreting). It will do this over and over, even though finding the right function call for an instruction may be quite slow.
A JIT compiler takes an instruction and translates it into native code, then runs that native code. This may take a bit longer than interpretation on the first go, but as soon as the code is called a second time, it no longer needs to be translated, but runs natively and much faster.