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:
| Year | Milestone |
|---|---|
| 1991 | James Gosling begins the "Green Project" — Java was initially called Oak |
| 1995 | Java 1.0 released publicly by Sun Microsystems |
| 1998 | Java 2 (J2SE 1.2) introduced — Swing, Collections Framework |
| 2004 | Java 5 — Generics, Annotations, Enums, Autoboxing |
| 2010 | Oracle acquires Sun Microsystems |
| 2014 | Java 8 — Lambda Expressions, Stream API, Date/Time API |
| 2017 | Java 9 — Module System (Project Jigsaw), 6-month release cycle begins |
| 2021 | Java 17 LTS — Sealed Classes, Pattern Matching |
| 2023 | Java 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:
| Edition | Full Name | Use Case |
|---|---|---|
| Java SE | Standard Edition | Core language, desktop apps |
| Java EE | Enterprise Edition (now Jakarta EE) | Large-scale enterprise applications, web services |
| Java ME | Micro Edition | Mobile and embedded devices |
How Java Works
Here's how a Java program goes from source code to execution:
- Write — You write Java code in a
.javafile - Compile — The
javaccompiler converts it to bytecode (.classfile) - Load — The JVM's ClassLoader loads the bytecode
- Verify — The Bytecode Verifier checks the code for security
- Execute — The JVM's interpreter (or JIT compiler) executes the bytecode
Your First Java Program
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 namedHelloWorld. The filename must match:HelloWorld.javapublic static void main(String[] args)— The main method, the entry point of every Java applicationSystem.out.println(...)— Prints text to the console followed by a new line
Why Learn Java?
- Massive Job Market — Java consistently ranks among the top 3 most in-demand programming languages
- Android Development — Java is the primary language for Android app development
- Enterprise Dominance — Banks, healthcare, government systems run on Java
- Strong Community — Millions of developers, thousands of libraries and frameworks
- 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