DEV Community

Pavithra C
Pavithra C

Posted on

1

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

If this article connected with you, consider tapping ❤️ or leaving a brief comment to share your thoughts!

Okay