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

Java History & Features

Java was created so programs could be written once and run on many kinds of computers. Its features make it safe, organized, and able to do many jobs at once.

History of Java

James Gosling led the team that created Java at Sun Microsystems, first releasing it in 1995 under the name Oak before renaming it Java -- the goal from the start was a simpler, safer alternative to C++.

Example: History of Java

java
// Define the class Main
public class Main {
	// Program entry point: the JVM starts running here
	public static void main(String[] args) {
		// Declare originalName and set it to "Oak"
		String originalName = "Oak";
		// Declare releaseYear and set it to "1995"
		String releaseYear = "1995";
		// Print a line to the console
		System.out.println("Java was created by James Gosling at Sun Microsystems in " + releaseYear + ", originally named " + originalName + ".");
	}
}

Platform Independence

Because the compiler targets bytecode instead of a specific CPU's machine code, the exact same compiled program runs unmodified on any operating system that has a JVM installed.

Example: Platform Independence

java
public class Main {
	public static void main(String[] args) {
		// This same Main.class file runs unmodified on Windows, Linux, and macOS
		System.out.println("Compiled once, runs on any OS with a JVM installed.");
	}
}

Object-Oriented Programming

Java forces you to model your program as classes and objects from the ground up, which encourages breaking large problems into smaller, testable, reusable pieces rather than one long procedural script.

Example: Object-Oriented Programming

java
// Define the class Task
class Task {
	String name;
	Task(String name) { this.name = name; }
	void run() { System.out.println("Running: " + name); }
}
// Define the class Main
public class Main {
	// Program entry point: the JVM starts running here
	public static void main(String[] args) {
		// Create a new Task object and store it in task
		Task task = new Task("Send Email");
		task.run();
	}
}

Robustness and Security

The JVM validates bytecode before running it, enforces array bounds checking, and gives you no raw pointers to corrupt memory with -- trade-offs that sacrifice some raw speed for far fewer crash-causing bugs.

Example: Robustness and Security

java
public class Main {
	public static void main(String[] args) {
		int[] numbers = {1, 2, 3};
		try {
			System.out.println(numbers[5]); // out-of-bounds access
		} catch (ArrayIndexOutOfBoundsException e) {
			System.out.println("Caught by JVM bounds checking: " + e.getMessage());
		}
	}
}

Multi-threading Support

Since threads are a first-class part of the language (via the Thread class and java.util.concurrent), you can genuinely run independent tasks in parallel to keep a CPU-bound or I/O-bound program responsive.

Example: Multi-threading Support

java
// Define the class Main
public class Main {
	// Program entry point: the JVM starts running here
	public static void main(String[] args) throws InterruptedException {
		// Create a new Thread object and store it in worker
		Thread worker = new Thread(() -> System.out.println("Running independently on its own thread"));
		// Start the thread; it runs in parallel with this code
		worker.start();
		// Wait for the thread to finish
		worker.join();
	}
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Saying Java has no pointers so it has no memory problems, when object references can still be null and cause NullPointerException.
  2. Assuming "platform independent" means the same .java compiles anywhere without a JDK, when the bytecode needs a JVM on the target machine.
  3. Thinking automatic garbage collection means you can never leak memory, when objects that stay referenced are never freed.

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.