About Java operating mechanism

Java operating mechanism

Java is both a compiled language, is an interpreted language.

First to find characteristics and operational mechanisms for the two languages.

The difference between compiled languages ​​and interpreted languages

Compiled language

What is it compiled? By looking for information, probably using a special compiler for a particular platform will be a one-time high-level language source code "translated" into machine code that can be platform and its implementation, and packaged into an executable program that can be recognized by the platform format. ps: The computer can not read, of course we have to knock code.

Interpreted language

It is explained by a special interpreter to interpret the source code into machine code and platform needed to execute immediately, that is, before each execution, we need to explain it again.

Breakdown of difference between the two

  • Compiled executable program can be detached development environment (but if you want to move to another platform, you will need to source additional copy platform, and recompile), and interpreted language program can not be run independently from the interpreter, but cross-platform easily.
  • The execution speed of a compiled language that is quite fast, because before senior program has been compiled into machine language file, for example windows下的exe文件, when running the executable does not need to be recompiled, but directly run. The programs written in interpreted languages Each time, we must translate once, the efficiency is low.
  • Compiled program can access any area of ​​memory, less secure, and of course interpreted very safe in this area, very intimate.
  • Compiled programs run consumes less memory than interpreted a little while before running the compiler must first open the relevant interpreter, and will be a lot of code optimization, security checks, resource consumption, take up memory.
  • But the compiled code really hard so hard, c language is typical of a compiled language, while intelligent interpreter after all, you know what I mean.

C, C ++, Objective-C, Pascal and other high-level languages ​​are compiled language.

Ruby, Python and other languages ​​are interpreted languages.

And Java is very strange, really strange, and compiled and interpreted.

Java strange place

Java compiler

Java compiler does not generate platform-specific machine code, but a platform-independent byte code, which is the .classfile.

Java interpretation

.classFile by the Java virtual machine, that machine code to JVM (Java Virtual Machine) translated into the execution, which is the process of interpretation.

Specific mechanisms

  • After bytecode compiler-generated platform does not face, but the JVM, JVM as a switch to a byte code are translated into different platforms need, this is the crux of cross-platform Java is reflected at.

  • Step execution of Java programs below shows:

    gdyxJ7.png

  • JDK (Java Runtime Environment) provides javac.exefor the preparation of .javafiles are compiled to form a byte code file, and Java.exeload the Java class files, and gradually bytecode files compiled.

  • In this Acknowledgment:

Guess you like

Origin www.cnblogs.com/summerday152/p/11809232.html