π Naming Conventions
File name must match the public class name (e.g.,
Hello.java)Class names β
PascalCase(e.g.,MyFirstProgram)Method and variable names β
camelCase(e.g.,printMessage())
π How Java Code Runs (Behind the Scenes)
β Programmer Writes Code
The programmer creates a file like
Hello.java.This file contains Java source codeβhuman-readable instructions.
π File Created: Hello.java
π§ You: Write the code using an editor (like VS Code, IntelliJ, or Notepad).
β Compilation using JDK
The JDK (Java Development Kit) includes a compiler (
javac) that converts.javainto.class.
π οΈ javac Hello.java β Produces β Hello.class
πΉ .class file contains bytecode, which is platform-independent.
β Running the Code using JRE
You run the code using the
java Hellocommand.This sends the
.classfile (bytecode) to the JRE (Java Runtime Environment).
β JRE β What Happens Inside
The JRE contains:
πΈ JVM (Java Virtual Machine):
It reads the
.classbytecode.Converts it to machine-specific code (native code).
This is where the actual execution happens.
πΈ JIT Compiler (Just-In-Time):
JIT improves performance by converting frequently-used bytecode into machine code just in time for execution.
πΈ Built-in Libraries:
JRE also includes core Java libraries (.class files, APIs) required during execution.
β Execution on the Computer
The JVM executes the machine code on your computer hardware (CPU, memory).
Finally, you see the output on your screen.

β οΈ Common Output Issue
If you see nothing or an error:
Check that the file name matches the class name.
Make sure the main method is spelled exactly like:
public static void main(String[] args)