DAY-06:Java compilation summary

Compilation in Java:

  1. You write Java code in a .java file.
  2. The Java compiler (javac) compiles the .java file into an intermediate format called .class file (bytecode).
  3. The .class file contains platform-independent bytecode.

Interpretation in Java:

  1. The .class file (bytecode)is executed by the Java Virtual Machine (JVM).
  2. The JVM interprets the bytecode line by line and executes it on the fly.
  3. The JVM provides a platform-dependent implementation, allowing the bytecode to run on any platform that has a JVM.

Key differences:

  • Compilation: Java code is compiled into bytecode beforehand.
  • Interpretation: Bytecode is interpreted and executed by the JVM at runtime.

Character User Interface (CUI)

  • A text-based interface where users interact using commands and receive text-based output.

Graphical User Interface (GUI)

  • A visual interface where users interact using graphical elements like buttons, menus, and icons.

TERMINAL:

  1. ls—>listing file
  2. javac First.java
  3. java First javac—>To compile java program

code working:
Source Code → Intermediate Code → Byte Code → Machine Code

  1. compilation-source code to Byte code
  2. Execution-Byte code to Binary code

Java programme:
public class First
{
public static void main(String[] args)
{
System.out.println(“Welcome To Java”);
}
}

step-by-step Java compilation process:

  1. Write Java Code: Create a Java program in a file with a .java extension (e.g., First.java).

  2. Compile Java Code: Use the javac command to compile the Java code into bytecode (e.g., javac First.java).

  3. Generate Bytecode: The javac command generates a .class file (e.g., HelloWorld.class) containing the bytecode.

  4. Load Bytecode: The Java Virtual Machine (JVM) loads the .class file into memory.

  5. Execute Bytecode: The JVM executes the bytecode, running the Java program.

原文链接:DAY-06:Java compilation summary

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
Do not let dream just be your dream.
别让梦想只停留在梦里
评论 抢沙发

请登录后发表评论

    暂无评论内容