0% found this document useful (0 votes)
12 views2 pages

Java Compilation Process Explained

Java is a compiled and interpreted language that involves writing code in a .java file, which is then compiled into bytecode by the Java Compiler (javac). This bytecode is platform-independent and executed by the Java Virtual Machine (JVM) using the Just-In-Time (JIT) compiler. The process ensures Java's 'Write Once, Run Anywhere' capability.

Uploaded by

himanshu20social
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Java Compilation Process Explained

Java is a compiled and interpreted language that involves writing code in a .java file, which is then compiled into bytecode by the Java Compiler (javac). This bytecode is platform-independent and executed by the Java Virtual Machine (JVM) using the Just-In-Time (JIT) compiler. The process ensures Java's 'Write Once, Run Anywhere' capability.

Uploaded by

himanshu20social
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

History and Features of Java

How Java Works (Compilation and Execution)

Java is both a compiled and interpreted language. Here's how a Java program runs from source code to

execution:

1. **Writing the Code (.java file)**

- A developer writes code in a `.java` file using a text editor or IDE.

- Example: `[Link]`

2. **Compilation (javac)**

- The Java Compiler (`javac`) compiles the `.java` file.

- It checks for syntax errors and converts the source code into **bytecode**.

- Output: A `.class` file (e.g., `[Link]`).

3. **Bytecode**

- Bytecode is an intermediate, platform-independent code.

- It is not directly executable by the OS.

- Ensures Java's 'Write Once, Run Anywhere' feature.

4. **Execution (java)**

- The Java Virtual Machine (`java`) loads the `.class` file.

- JVM interprets or compiles the bytecode into machine code using the **Just-In-Time (JIT) compiler**.

- The program is then executed by the CPU.

-> Example Flow:


History and Features of Java

1. Write code: `[Link]`

2. Compile: `javac [Link]` -> generates `[Link]`

3. Run: `java HelloWorld` -> JVM executes the bytecode

**Summary:**

- `.java` -> compiled by `javac` -> `.class` (bytecode)

- `.class` -> run by `java` command -> executed by JVM

You might also like