← Back to Core Java Course | Chapter 1: Introduction & Basics | Lesson 3 of 12

Java Environment Setup

What is the JDK?

The JDK bundles everything you need to build Java software: the javac compiler, the java launcher, debugging tools, and the JRE (which itself contains the JVM and core class libraries) needed just to run compiled programs.

Example: What is the JDK?

java
public class Main {
	// The JDK provides: javac (compiler), java (launcher), debugging tools, and the JRE/JVM
	public static void main(String[] args) {
		System.out.println("Built and run using tools bundled in the JDK.");
	}
}

Writing Your Code

Any plain text editor works, but IDEs like IntelliJ IDEA, Eclipse, or VS Code with the Java extension pack add real value here -- autocomplete, inline error highlighting, and one-click running that make catching typos far faster.

Example: Writing Your Code

java
public class Main {
	// Written in an IDE like IntelliJ IDEA, Eclipse, or VS Code (Java extension pack)
	public static void main(String[] args) {
		System.out.println("Code written with autocomplete and inline error highlighting.");
	}
}

Saving Your File

Java is strict about this: if your file declares public class Calculator, it must be saved as Calculator.java exactly, matching case, or the compiler will refuse to build it.

Example: Saving Your File

java
public class Calculator {
	// This file MUST be saved as Calculator.java, matching the class name exactly (case-sensitive)
	public static void main(String[] args) {
		System.out.println("Saved as Calculator.java to match 'public class Calculator'.");
	}
}

Compiling Your Code

Running javac filename.java from your terminal reads your source, checks it for syntax and type errors, and if it's clean, emits a matching filename.class file containing JVM bytecode in the same folder.

Example: Compiling Your Code

java
public class Main {
	// Terminal: javac Main.java
	// Checks syntax/types, then emits Main.class (JVM bytecode) in the same folder
	public static void main(String[] args) {
		System.out.println("Compiled with: javac Main.java");
	}
}

Running the Bytecode

The java ClassName command (note: no .java or .class extension here) loads that bytecode file and hands it to the JVM, which begins executing from your program's main method.

Example: Running the Bytecode

java
public class Main {
	// Terminal: java Main   (no .java or .class extension)
	public static void main(String[] args) {
		System.out.println("Executed by the JVM starting from main().");
	}
}

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.