How the Java language works

My knowledge of Java is small, so I want to ask how the language works. By this I mean not only "language", but also a virtual machine.

Here is my understanding.

  • The Java compiler turns code into Java bytecode. as a .java file
  • when the file is launched, the JVM reads (just in time) the bytecode and turns it into machine code.
  • The computer reads the machine code, and the program runs as a compiled program (to the user).

Is this hopelessly wrong?

+3
source share
6 answers

There are already many answers, but I miss one important point:

"2. When the file is launched, the JVM reads (just in time) the bytecode and turns it into machine code.

This is not entirely correct.

  • JVM
  • ,
  • , ..
  • ,

. (, ), , , JVM , .

+3

Java (JVM) - , - Java java-. Java , .

Java . JVM . -, . Java , Java.

java, JVM, , Java. Java - .

+2

.

0

:

  • Java- .class .java , ..java .
  • JVM ( Java) () . . JVM.
  • JIT ( ) , JVM ( ).
0

,

  • java, .java

  • At compile time, the compiler converts the code (.java file) to .class (byte code).

  • When the code runs, the JVM converts the byte code (.class file) into Machine Code, which can be interpreted by the OS. Thus, it makes Java as platform independent and the JVM as platform dependent.

0
source

Source: https://habr.com/ru/post/1790500/


All Articles