What is JDK, Components and how it works

What is JDK?
JDK stands for Java Development Kit.
It is a software package that provides everything you need to write, compile, and run Java programs.
Think of the JDK as a toolbox for Java developers. Inside the box, you’ll find tools to write code, convert it to a format the machine understands, and run it.
Components of JDK
The JDK includes several important tools and libraries. Here's a simple breakdown:
JRE (Java Runtime Environment)
It allows running Java programs.
Contains:
JVM (Java Virtual Machine) – Runs Java bytecode.
Libraries – Pre-built Java code for tasks like reading files, networking, math, etc.
JVM (Java Virtual Machine)
It executes the
.class
file (compiled Java bytecode).It makes Java platform-independent, meaning the same Java code runs on Windows, Linux, Mac, etc.
Works with memory management, security, and performance.
Java Compiler (javac
)
Converts
.java
files (your code) into.class
files (bytecode).example:
javac HelloWorld.java
Development Tools
Tools like:
javadoc
– Generates documentation.javap
– Shows the structure of class files.jdb
– Java debugger.
How Java Works (Step-by-Step)
Let’s understand what happens from writing code to running it:
Writing code
You write Java code in a file with a .java
extension.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Step 2: Compile the Code (javac
)
Use the Java compiler to convert .java
to .class
(bytecode).
javac HelloWorld.java
✅ Output: A file HelloWorld.class
is created.
Step 3: Run the Program (java
)
Use the Java launcher to run the program.
java HelloWorld
✅ Output on the console:
Hello, World!
Behind the scenes:
JVM loads the
HelloWorld.class
.It interprets or compiles the bytecode.
Executes the code line by line.
Subscribe to my newsletter
Read articles from Sheeshpal Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
