Is java a Just In Time compiler (JIT) or is java compiled by the programmer with javac. If both, whats the benefit of each?
Asked
Active
Viewed 229 times
0
-
The answer is 'both'. – user207421 Aug 09 '16 at 05:57
1 Answers
-1
Java is compiled into Java Bytecodes. Those bytecodes are then interpreted by the Java Virtual Machine at runtime. So technically neither.

ArthuruhtrA
- 27
- 9
-
1JIT compilation != interpretation. The HotSpot JVM interprets bytecode at first and then JIT-compiles methods that are called a lot. Previous JVMs only interpreted the bytecode. In that case there'd be no JIT compilation going on. – sepp2k Aug 09 '16 at 11:58
-
Is the difference that the bytecode can't be modified while running? – ArthuruhtrA Aug 09 '16 at 12:02
-
The difference is that JIT compilation translates the bytecode to machine code (i.e. it compiles it) and then runs the machine code, whereas interpretation simply executes the bytecode without compiling anything. – sepp2k Aug 09 '16 at 12:24
-
How can it execute without translating it to something the processor can understand? – ArthuruhtrA Aug 09 '16 at 12:29
-
Something like `if(instruction.isAdd()) { memory[instruction.target()] += instruction.argument(); } else if ...` – sepp2k Aug 09 '16 at 12:42
-
@ArthuruhtrA The same way your favorite calculator program can "execute" `2+3`. The processor understands the interpreter program; the interpreter, in turn, understands the bytecode. – Martin Törnwall Aug 09 '16 at 17:58
-