compile once,run anywhere

Compile once, run everywhere; refers to the cross-platform capability of the Java language, and this capability is mainly provided by the Java virtual machine. How does the Java language compile and run from source code to executable machine code? The Java source code is compiled by javac to generate bytecode that shields the operating system and hardware, and then compiled and interpreted by the JVM.

The Java language provides three execution modes for bytecode files:

  1. Interpret and execute, translate and execute code one by one
  2. Compile and execute (dynamic compilation), and JIT (existing in JVM, Java in time, Java just-in-time compiler) compiles hot code (code with high frequency) into machine code
  3. AOT secondary compilation, first form a static binary file, specify the static file at runtime, you need to manually specify, use the jaotc tool to achieve static compilation

Choose how the Java bytecode is executed by specifying parameters:

  1. java -Xmixed parameter, the way to compile and interpret mixed execution, the default way
  2. java -Xint, interpret (interpret) execution
  3. java -Xcomp compile (compile) execution
  4. The jaotc tool specifies a static compilation module, which can be loaded at runtime

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325291574&siteId=291194637