Java is a high-level, object-oriented, class-based programming language and software platform.
It was developed at Sun Microsystems and publicly introduced in 1995.
Java is used to build:
- Web applications
- Backend/API applications
- Enterprise software
- Banking systems
- Cloud applications
- Distributed systems
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}Output:
Hello, World!
Java Source
↓
Compiler
↓
Bytecode
↓
JVM
↓
Output
The famous idea behind Java is:
Write Once, Run Anywhere
The programming language.
Java Development Kit
Used to develop Java programs.
It includes tools such as the Java compiler.
JDK
├── javac
├── Java tools
├── Libraries
└── JVM/runtime components
Java Virtual Machine
Used to execute Java bytecode.
Hello.java
↓
javac
↓
Hello.class
↓
Bytecode
↓
JVM
↓
Program runs
Suppose you have the same Java program on Windows and Linux.
You don't normally compile it directly into Windows-specific or Linux-specific machine code.
Instead:
Java Bytecode
↓
┌─────────┴─────────┐
↓ ↓
Windows JVM Linux JVM
↓ ↓
Windows Linux
The JVM provides the platform-specific layer.
That's the core reason Java became portable.
Java is commonly described as:
- Simple
- Object-oriented
- Platform-independent
- Secure
- Robust
- Portable
- Multithreaded
- High-performance through JVM optimization
- Distributed/network-friendly
- Dynamically extensible
Now let's understand what actually happens inside the JVM.
int x = 10;
int y = 20;
System.out.println(x + y);The Java compiler:
javac
converts the source code into bytecode.
.java
↓
javac
↓
.class
The JVM loads and verifies classes before executing them.
The JVM can interpret bytecode and, in modern implementations, use JIT compilation to compile frequently executed code into optimized native machine code.
Bytecode
↓
JVM
↓
Interpretation + JIT optimization
↓
Native execution
Java uses garbage collection.
When objects are no longer reachable by the application, the JVM can reclaim their memory.
Create object
↓
Use object
↓
No longer reachable
↓
Garbage Collector
↓
Memory reclaimed
Java organizes programs around classes and objects.
Example:
class Student {
String name;
void study() {
System.out.println(name + " is studying");
}
}Create an object:
Student s = new Student();
s.name = "Rahul";
s.study();The four major OOP concepts are:
OOP
│
┌─────────┼─────────┐
↓ ↓ ↓
Encapsulation Inheritance Polymorphism
│
Abstraction
The easiest deep mental model is:
┌─────────────────────────────┐
│ Java Application │
├─────────────────────────────┤
│ Java Libraries │
├─────────────────────────────┤
│ JVM │
│ ┌──────┬───────┬─────────┐ │
│ │ GC │ JIT │ Runtime │ │
│ └──────┴───────┴─────────┘ │
├─────────────────────────────┤
│ Operating System │
├─────────────────────────────┤
│ Hardware │
└─────────────────────────────┘
This architecture is what makes Java more than just a language.
Java = programming language
JDK = development
JVM = execution
Bytecode = intermediate code
.java
↓
javac
↓
.class
↓
JVM
↓
Execution
Java is popular because of:
Portability + OOP + Security + Garbage Collection + Huge Ecosystem
The real power of Java comes from the JVM.
Source Code
↓
Compiler
↓
Bytecode
↓
Class Loading + Verification
↓
JVM
↓
Interpreter / JIT
↓
Native execution
Meanwhile, the JVM manages memory, garbage collection, threads, exceptions, and runtime optimization.
Java is a high-level, object-oriented programming language whose programs are compiled into bytecode and executed by the JVM, providing portability across different platforms.