Clean β’ Professional
Before diving deep into Core Java concepts, itβs essential to understand the Java workflow β how a Java program is written, compiled, and executed.
This guide walks you through each step using simple examples and command-line instructions.
Create a Java file with the .java extension. The file name should match the class name.
Example: HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
| Part | Description |
|---|---|
public class HelloWorld | Declares a class named HelloWorld |
public static void main(String[] args) | Entry point of the program |
System.out.println("Hello, Java!"); | Prints text to the console |
Every Java program must have a main method to run.
Compile your source code (.java) into bytecode (.class) using the Java compiler:
javac HelloWorld.java
HelloWorld.class.Execute the compiled bytecode using the JVM:
java HelloWorld
Output:
Hello, Java!
The JVM reads the bytecode and converts it into machine code for your system.
Java development is iterative:
Write β Compile β Run β Fix Errors β Re-runCommon Issues & Fixes:
| Issue | Fix |
|---|---|
| Syntax Errors | Check semicolons, brackets, and case sensitivity |
| Class Name Mismatch | File name must match the public class name |
| PATH/JDK Not Set | Add JDK bin folder to your system PATH |
| Cannot Find Symbol | Verify variable/method names |
For advanced workflows or bigger projects, you can use Maven or Gradle to:
1οΈβ£ Write Java Source Code (.java)
β
2οΈβ£ Compile (javac) β Bytecode (.class)
β
3οΈβ£ Run (java) β JVM executes bytecode
β
4οΈβ£ Output & Debug β Improve Code
.java file.class)| Step | Action |
|---|---|
| Write Code | Create .java file with main class |
| Compile | Use javac to generate .class bytecode |
| Run | Execute with java command via JVM |
| Debug | Fix errors and iterate |
| Optional | Use Maven/Gradle for larger projects |