Getting Started

Introduction to Java

Learn what Java is, its history, key features, and why it remains one of the most popular programming languages in the world.

What is Java?

Java is a high-level, class-based, object-oriented programming language designed to have as few implementation dependencies as possible. It follows the principle of "Write Once, Run Anywhere" (WORA), meaning compiled Java code can run on all platforms that support Java without the need for recompilation.

Java is used in a wide variety of applications — from mobile apps (Android) and web applications to enterprise systems, scientific computing, and big data technologies.

History of Java

Java was originally developed by James Gosling and his team at Sun Microsystems (now owned by Oracle Corporation) in 1995. Here's a brief timeline:

YearMilestone
1991James Gosling begins the "Green Project" — Java was initially called Oak
1995Java 1.0 released publicly by Sun Microsystems
1998Java 2 (J2SE 1.2) introduced — Swing, Collections Framework
2004Java 5 — Generics, Annotations, Enums, Autoboxing
2010Oracle acquires Sun Microsystems
2014Java 8 — Lambda Expressions, Stream API, Date/Time API
2017Java 9 — Module System (Project Jigsaw), 6-month release cycle begins
2021Java 17 LTS — Sealed Classes, Pattern Matching
2023Java 21 LTS — Virtual Threads, Record Patterns

Key Features of Java

1. Platform Independent

Java code is compiled into bytecode (.class files) by the Java Compiler (javac). This bytecode runs on the Java Virtual Machine (JVM), which is available for every major operating system.

Java Source Code (.java)
        ↓
   Java Compiler (javac)
        ↓
   Bytecode (.class)
        ↓
   JVM (Windows / Mac / Linux)
        ↓
   Machine Code (Executed)

2. Object-Oriented

Everything in Java is an object (except primitive types). Java supports all four pillars of OOP:

  • Encapsulation — Bundling data and methods together
  • Inheritance — Reusing code from parent classes
  • Polymorphism — One interface, multiple implementations
  • Abstraction — Hiding complexity, showing essentials

3. Robust and Secure

  • Strong memory management with automatic Garbage Collection
  • Exception handling to manage runtime errors gracefully
  • No explicit pointers (reduces memory corruption risks)
  • Built-in security manager and bytecode verifier

4. Multithreaded

Java has built-in support for multithreaded programming, allowing you to write programs that perform multiple tasks simultaneously. This is essential for building responsive applications and high-performance servers.

5. Rich Standard Library

Java comes with a massive standard library (the Java API) that provides:

  • Data structures (Lists, Maps, Sets)
  • I/O operations
  • Networking
  • Database connectivity (JDBC)
  • GUI development (Swing, JavaFX)
  • And much more

Java Editions

Java comes in three main editions:

EditionFull NameUse Case
Java SEStandard EditionCore language, desktop apps
Java EEEnterprise Edition (now Jakarta EE)Large-scale enterprise applications, web services
Java MEMicro EditionMobile and embedded devices

How Java Works

Here's how a Java program goes from source code to execution:

  1. Write — You write Java code in a .java file
  2. Compile — The javac compiler converts it to bytecode (.class file)
  3. Load — The JVM's ClassLoader loads the bytecode
  4. Verify — The Bytecode Verifier checks the code for security
  5. Execute — The JVM's interpreter (or JIT compiler) executes the bytecode

Your First Java Program

java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Output:

Hello, World!

Let's break this down:

  • public class HelloWorld — Declares a public class named HelloWorld. The filename must match: HelloWorld.java
  • public static void main(String[] args) — The main method, the entry point of every Java application
  • System.out.println(...) — Prints text to the console followed by a new line

Why Learn Java?

  1. Massive Job Market — Java consistently ranks among the top 3 most in-demand programming languages
  2. Android Development — Java is the primary language for Android app development
  3. Enterprise Dominance — Banks, healthcare, government systems run on Java
  4. Strong Community — Millions of developers, thousands of libraries and frameworks
  5. Long-term Stability — Java has been reliable for 25+ years with strong backward compatibility

Summary

  • Java is a high-level, object-oriented, platform-independent programming language
  • It was created by James Gosling at Sun Microsystems in 1995
  • Java code compiles to bytecode that runs on the JVM — "Write Once, Run Anywhere"
  • It supports OOP, multithreading, automatic memory management, and has a vast standard library
  • Java is used in Android apps, enterprise systems, web development, and more
  • There are three editions: Java SE, Java EE (Jakarta EE), and Java ME