Java was developed by James Gosling and his team (known as the "Green Team") at Sun Microsystems in 1991.
-
Originally named "Oak" (after an oak tree outside Gosling's office)
-
Later renamed to "Java" (inspired by Java coffee)
-
Initial goal: Create a language for embedded systems and interactive television
-
Official release: May 23, 1995 — Java 1.0
Timeline:
1991 → Project Green started
1995 → Java 1.0 released
2006 → Sun Microsystems open-sourced Java
2010 → Oracle acquired Sun Microsystems
The Green Team wanted to solve key problems in software development:
| Problem | Java's Solution |
|---|---|
| Platform dependency (C++) | Platform-independent bytecode |
| Memory management | Automatic garbage collection |
| Pointer complexity | No explicit pointers |
| Security vulnerabilities | Built-in security features |
| Complex syntax | Simple, clean OOP-based syntax |
| Version | Year | Key Features |
|---|---|---|
| Java 1.0 | 1996 | Initial release |
| Java 1.2 | 1998 | Collections Framework, JIT compiler |
| Java 5 | 2004 | Generics, Annotations, Enums, Autoboxing |
| Java 8 | 2014 | Lambda Expressions, Stream API, Functional Programming |
| Java 9 | 2017 | Module System (Project Jigsaw), JShell |
| Java 11 | 2018 | LTS, HTTP Client API, var for lambda parameters |
| Java 17 | 2021 | LTS, Sealed Classes, Pattern Matching |
| Java 21 | 2023 | LTS, Virtual Threads, Record Patterns, Pattern Matching |
LTS = Long-Term Support (supported for 8+ years)
Java is known as a robust, secure, and platform-independent programming language.
Java has:
-
Clean, readable syntax inspired by C/C++
-
Automatic memory management (Garbage Collection)
-
No pointers, no operator overloading
-
Rich standard library
// Simple Hello World
public class Demo {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}Java code is compiled to bytecode, not machine code.
Source Code (.java) → Compiler (javac) → Bytecode (.class) → JVM (any platform)
-
Bytecode is platform-independent
-
JVM is platform-dependent (Windows, Linux, macOS have different JVMs)
-
Same
.classfile runs on any system with JVM
// Example
public class Test {
public static void main(String[] args) {
System.out.println("Runs on any OS!");
}
}✅ Same bytecode runs on Windows, Linux, macOS.
Java is purely object-oriented (except primitives).
OOP Pillars:
| Concept | Description |
|---|---|
| Encapsulation | Bundling data and methods together |
| Inheritance | Reusing code from parent classes |
| Polymorphism | Same method, different behavior |
| Abstraction | Hiding implementation details |
class Animal {
void sound() {
System.out.println("Animal makes sound");
}
}
class Dog extends Animal {
void sound() {
System.out.println("Dog barks");
}
}Robust:
-
Strong type checking at compile time
-
Exception handling (
try-catch) -
Automatic garbage collection
-
No pointer arithmetic
Secure:
-
Bytecode verifier checks for illegal code
-
No explicit pointers → prevents memory manipulation
-
Security Manager controls access to resources
-
ClassLoader provides namespace isolation
Java has built-in support for multithreading.
-
Execute multiple threads concurrently
-
Efficient CPU utilization
-
Built-in
Threadclass andRunnableinterface
class MyThread extends Thread {
public void run() {
System.out.println("Thread is running");
}
}
public class Demo {
public static void main(String[] args) {
MyThread t = new MyThread();
t.start(); // starts a new thread
}
}Java automatically manages memory using Garbage Collection (GC).
-
Developers don't need to manually free memory
-
GC removes unused objects from heap memory
-
Prevents memory leaks
// Object created on heap
Student s = new Student();
// When no reference exists, GC removes it automatically
s = null; // eligible for garbage collectionJava uses Just-In-Time (JIT) Compiler:
-
Converts frequently executed bytecode into native machine code at runtime
-
Improves execution speed significantly
Bytecode → JIT Compiler → Native Machine Code (faster execution)
Java supports distributed applications:
-
RMI (Remote Method Invocation)
-
EJB (Enterprise JavaBeans)
-
Web Services
-
Networking APIs (
Socket,URL,HttpClient)
-
Java can load classes dynamically at runtime
-
Reflection API allows inspection of classes/methods at runtime
Class<?> c = Class.forName("java.lang.String");
System.out.println(c.getName()); // java.lang.StringJava provides extensive libraries:
| Library | Purpose |
|---|---|
java.lang |
Core classes (String, Math) |
java.util |
Collections, Date/Time |
java.io |
File I/O operations |
java.net |
Networking |
java.sql |
Database connectivity |
java.awt/swing |
GUI development |
| Feature | Java | C++ | Python |
|---|---|---|---|
| Platform Independence | ✅ Yes (JVM) | ❌ No | ✅ Yes (interpreter) |
| Memory Management | Automatic (GC) | Manual (new/delete) | Automatic (GC) |
| Pointers | ❌ No | ✅ Yes | ❌ No |
| Multithreading | Built-in | Library-based | Built-in (GIL) |
| Performance | High (JIT) | Very High (compiled) | Lower (interpreted) |
| Type System | Static | Static | Dynamic |
| Syntax | Moderate | Complex | Simple |
Java is used in:
| Application Area | Examples |
|---|---|
| Web Applications | Spring Boot, JSP, Servlets |
| Android Development | Android apps |
| Enterprise Systems | Banking, E-commerce, ERP systems |
| Big Data | Hadoop, Apache Spark |
| Cloud Computing | AWS, Azure, Google Cloud services |
| Desktop Applications | IntelliJ IDEA, Eclipse IDE |
| Embedded Systems | Smart cards, IoT devices |
| Scientific Computing | MATLAB, simulation tools |
James Gosling defined 5 design goals for Java:
-
Simple, Object-Oriented, and Familiar
- Based on C++ but simpler
-
Robust and Secure
- Strong type checking, exception handling
-
Architecture-Neutral and Portable
- Bytecode runs on any platform
-
High Performance
- JIT compiler optimizations
-
Interpreted, Threaded, and Dynamic
- Bytecode interpreted by JVM
- Built-in multithreading support
Step 1: Write code
Demo.java
Step 2: Compile
javac Demo.java → Demo.class (bytecode)
Step 3: Execute
java Demo → JVM interprets bytecode
Detailed Flow:
.java → javac (Compiler) → .class (Bytecode)
↓
JVM (Class Loader → Bytecode Verifier → Interpreter/JIT)
↓
Native Machine Code
↓
Execution
Q1: Why is Java called "Platform Independent"?
Java compiles to bytecode, which runs on JVM. JVM is platform-specific, but bytecode is not.
Q2: What does "Write Once, Run Anywhere" mean?
Same .class file (bytecode) runs on any OS that has JVM installed.
Q3: Is Java 100% object-oriented?
No. Primitives (int, char, float, etc.) are not objects.
Q4: Why doesn't Java have pointers?
To prevent:
- Memory manipulation
- Security vulnerabilities
- Errors caused by pointer arithmetic
Q5: What is Bytecode Verifier?
A component of JVM that checks bytecode for:
- Illegal instructions
- Type violations
- Stack overflows
Q6: What is JIT Compiler?
Just-In-Time Compiler converts frequently used bytecode into native machine code for faster execution.
Q7: What are the major Java versions used in production?
Java 8, Java 11, Java 17, Java 21 (all LTS versions)
Q8: Why was Java created?
To solve platform dependency, memory management, and security issues in C/C++.
Q9: What is the difference between JDK, JRE, and JVM?
- JDK = Development tools + JRE
- JRE = JVM + Libraries
- JVM = Executes bytecode
Q10: What are the key features of Java 8?
- Lambda Expressions
- Stream API
- Functional Interfaces
- Default and Static methods in interfaces
- Optional class
-
Large Community — Extensive documentation, forums, tutorials
-
Enterprise Adoption — Used by Google, Amazon, Netflix, LinkedIn
-
Rich Ecosystem — Spring, Hibernate, Apache libraries
-
Backward Compatibility — Old code runs on newer versions
-
Job Market Demand — High demand for Java developers
-
Android Development — Primary language for Android apps (along with Kotlin)
-
Java was created in 1995 by James Gosling at Sun Microsystems
-
Platform-independent due to bytecode and JVM
-
Object-oriented, robust, secure, and multithreaded
-
Uses automatic garbage collection for memory management
-
JIT compiler provides high performance
-
Used in web, mobile, enterprise, big data, and cloud applications
-
LTS versions: Java 8, 11, 17, 21