Is the JVM a compiler or an interpreter?

后端 未结 8 1063
傲寒
傲寒 2020-12-02 03:48

I have a very basic question about JVM: is it a compiler or an interpreter?

If it is an interpreter, then what about JIT compiler that exist inside the JVM?
If n

8条回答
  •  粉色の甜心
    2020-12-02 04:35

    JVM have both compiler and interpreter. Because the compiler compiles the code and generates bytecode. After that the interpreter converts bytecode to machine understandable code.

    Example: Write and compile a program and it runs on Windows. Take the .class file to another OS (Unix) and it will run because of interpreter that converts the bytecode to machine understandable code.

提交回复
热议问题