C

Core Java tutorial for beginners

Clean • Professional

Java Development Workflow: Write, Compile & Run Your First Program

2 minute

Java Development Workflow – Write, Compile & Run Your First Program

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.


Step 1: Write Your First Java Program

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!");
    }
}

Explanation:

PartDescription
public class HelloWorldDeclares 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.


Step 2: Compile Your Program

Compile your source code (.java) into bytecode (.class) using the Java compiler:

Command Line:

javac HelloWorld.java
  • On success, this generates HelloWorld.class.
  • If there are syntax errors, the compiler will display them with line numbers.

IDE (Eclipse / IntelliJ):

  • Click Run or Build; the IDE compiles your program automatically.

Step 3: Run Your Program

Execute the compiled bytecode using the JVM:

Command Line:

java HelloWorld

Output:

Hello, Java!

IDE:

  • Eclipse: Right-click → Run As → Java Application
  • IntelliJ: Click the green Run button

The JVM reads the bytecode and converts it into machine code for your system.


Step 4: Debug and Iterate

Java development is iterative:

Write → Compile → Run → Fix Errors → Re-run

Common Issues & Fixes:

IssueFix
Syntax ErrorsCheck semicolons, brackets, and case sensitivity
Class Name MismatchFile name must match the public class name
PATH/JDK Not SetAdd JDK bin folder to your system PATH
Cannot Find SymbolVerify variable/method names

Optional: Using Build Tools for Larger Projects

For advanced workflows or bigger projects, you can use Maven or Gradle to:

  • Automate compilation and execution
  • Manage dependencies
  • Simplify project structure

Workflow Visualization

1️⃣ Write Java Source Code (.java)
       ↓
2️⃣ Compile (javac) → Bytecode (.class)
       ↓
3️⃣ Run (java) → JVM executes bytecode
       ↓
4️⃣ Output & Debug → Improve Code

Concepts Learned

  • Java source code → .java file
  • Compilation → converts source code → bytecode (.class)
  • Execution → JVM converts bytecode → machine code
  • Main method → program entry point
  • Iterative development → write → compile → run → debug

Summary Table

StepAction
Write CodeCreate .java file with main class
CompileUse javac to generate .class bytecode
RunExecute with java command via JVM
DebugFix errors and iterate
OptionalUse Maven/Gradle for larger projects


Article 0 of 0