JDK (Java Development Kit)
Introduction
The Java Development Kit (JDK) is the complete development environment used to create Java applications. It provides the tools required to write, compile, debug, package, document, and run Java programs.
If you are learning Java or planning to develop Java applications, the JDK is the package you normally install on your computer. It includes the Java compiler and other development tools, along with the runtime components needed to execute Java programs.
Understanding the JDK is important because it explains what happens between writing Java source code and running the final application.
What is JDK?
JDK stands for Java Development Kit.
It is a collection of software tools required for Java application development. The JDK provides everything a developer needs to turn Java source code into executable Java bytecode and work with that application during development.
At a high level:
The most important idea is:
JDK is used to develop Java applications.
If you only want to write and compile Java programs, you need a JDK.
Why Do We Need the JDK?
A Java program starts as source code written by a developer.
For example:
public class Hello { public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}This source code cannot be directly executed by the JVM. It first needs to be compiled into Java bytecode.
The JDK provides the compiler and other tools required for this process.
Java Source Code ↓
JDK Compiler
↓
Java Bytecode
↓
JVM
↓
ApplicationThe JDK therefore plays an important role in the complete Java development process.
JDK Components
The JDK contains several tools that support different stages of Java development.
The most commonly used components include the Java compiler, Java launcher, documentation generator, packaging tool, interactive shell, debugger, and runtime-image builder.
JDK│
┌────────────┼────────────┐
↓ ↓ ↓
Compiler Tools Runtime
javac Environment
│ │
↓ ↓
Bytecode JVM
Java Compiler
The Java compiler is one of the most important components of the JDK.
It is provided through the javac command and converts Java source files into Java bytecode.
The general process is:
.java Source File
↓
javac
↓.class Bytecode File
For example, if you have a file named Hello.java, you can compile it using:
javac Hello.javaThe compiler produces a corresponding class file containing Java bytecode.
That bytecode can then be executed by a compatible JVM.
Java Launcher
The java command is used to launch a Java application.
After compiling a Java program, the resulting bytecode can be executed using the Java launcher.
Java Source ↓
javac
↓
Java Bytecode
↓
java
↓
JVM
↓
ProgramFor example:
java HelloThe launcher starts the JVM and loads the required class so that the program can execute.
Javadoc
Javadoc is a JDK tool used to generate documentation from comments written in Java source code.
Developers can add documentation comments to classes, methods, and other program elements.
For example:
/** * Calculates the total price of an order.
*/
public double calculateTotal() {
return 100.0;
}Javadoc can process these comments and generate HTML-based API documentation.
This is particularly useful for libraries and large development teams because developers can document how classes and methods should be used.
JAR
JAR stands for Java Archive.
The jar tool is used to package Java classes, resources, configuration files, and other application files into a single archive.
For example:
Application │
├── Class Files
├── Images
├── Configuration
└── Resources
↓
JARA JAR file makes it easier to distribute and organize Java applications and libraries.
Many Java applications and libraries are distributed as JAR files.
JShell
JShell is an interactive Java shell introduced in Java 9.
It allows developers to experiment with Java code without creating a complete Java source file and compiling it every time.
For example, you can use JShell to quickly test expressions, methods, and small pieces of Java code.
JShell ↓
Write Java Code
↓
Execute Immediately
↓
View ResultThis makes JShell particularly useful when learning Java or experimenting with an API.
JDB
JDB is the command-line debugger provided with the JDK.
A debugger allows developers to investigate what is happening while an application is running.
It can be used to:
Set breakpoints
Examine program execution
Inspect variables
Step through code
Investigate problems
Although modern IDEs provide more advanced graphical debugging tools, JDB demonstrates that debugging capabilities are also available directly from the JDK.
Jlink
Jlink is a JDK tool used to create a custom runtime image containing only the Java modules required by an application.
This can reduce the size of the runtime environment used to deploy an application.
The basic idea is:
Full JDK ↓
Application Dependencies
↓
Required Java Modules
↓
jlink
↓
Custom Runtime ImageThis is useful when deploying Java applications where a smaller runtime footprint is desirable.
JDK and the Runtime Environment
Conceptually, the JDK provides both the tools required for development and the runtime components required to execute Java applications.
The relationship can be represented as:
JDK │
├── Development Tools
│ ├── javac
│ ├── javadoc
│ ├── jar
│ ├── jshell
│ ├── jdb
│ └── jlink
│
└── Runtime
│
└── JVMThis is why installing a JDK is generally sufficient for someone who wants to both develop and run Java applications.
A separate standalone JRE is no longer distributed by Oracle as it was in older Java releases. For modern Java development, installing a JDK is the normal approach.
JDK vs JRE vs JVM
The three terms are related, but they have different purposes.
| Component | Main Purpose |
|---|---|
| JDK | Develop, compile, debug, package, and run Java applications |
| JRE | Provide the runtime environment needed to run Java applications |
| JVM | Execute Java bytecode |
A useful conceptual hierarchy is:
JDK │
└── Runtime Environment
│
└── JVMThe JDK is the development-focused layer. The JVM is the execution engine at the center of the Java runtime.
The important distinction is:
JDK is for development, while JVM is responsible for executing Java bytecode.
JDK Development Workflow
A typical Java development process looks like this:
Write Java Code ↓
javac
↓
Java Bytecode
↓
java
↓
JVM
↓
ApplicationDuring development, additional JDK tools can be used for documentation, debugging, packaging, experimentation, and creating custom runtime images.
JDK │
┌────────────┼────────────┐
↓ ↓ ↓
Compile Develop Package
javac jshell jar
│ │ │
└────────────┼─────────────┘
↓
Debug
jdb
↓
Deploy
jlinkJDK Versions and Distributions
The Java ecosystem includes different JDK distributions built and supported by different organizations.
OpenJDK is the open-source project that forms the foundation of many Java distributions. Different vendors build, test, package, and support their own distributions.
Some commonly encountered distributions include:
| Distribution | Vendor |
|---|---|
| OpenJDK | Open-source community |
| Oracle JDK | Oracle |
| Eclipse Temurin | Eclipse Adoptium |
| Amazon Corretto | Amazon |
| Azul Zulu | Azul |
| Microsoft Build of OpenJDK | Microsoft |
For learning Java, several of these distributions can be suitable. The choice generally depends on factors such as licensing, support policies, release schedules, and organizational requirements.
Which JDK Should You Install?
For someone learning Java or developing Java applications, installing a current Long-Term Support (LTS) JDK is usually a practical choice.
The exact distribution can depend on your project and organization.
For example, developers may choose:
OpenJDK
Eclipse Temurin
Oracle JDK
Amazon Corretto
Microsoft Build of OpenJDK
Azul Zulu
The important thing is that the installed JDK provides the Java version required by your project.
When Do You Need a JDK?
If you are learning Java, writing Java applications, compiling source code, running tests, debugging programs, or building Java libraries, you should install a JDK.
For example, a beginner learning Java will typically follow this workflow:
Install JDK ↓
Write Java Program
↓
Compile with javac
↓
Run with java
↓
Debug and TestA developer does not normally need to install a separate JRE alongside the JDK for basic Java development.
Advantages of JDK
The JDK provides a complete environment for Java development. Instead of installing separate tools for compilation, debugging, documentation, packaging, and runtime execution, developers can use the tools provided by the JDK.
Its major advantages include a complete Java development environment, a standard compiler, debugging and documentation tools, packaging support, runtime capabilities, and tools for creating optimized runtime images.
JDK in One Picture
JDK │
┌───────────────┼────────────────┐
│ │ │
Development Runtime Tools
│ │ │
┌───┼───┐ ↓ ┌─────┼─────┐
↓ ↓ ↓ JVM ↓ ↓ ↓
javac jar jshell javadoc jdb jlink
│
↓
Java Bytecode
│
↓
JVM
│
↓
Java ApplicationKey Takeaways
JDK stands for Java Development Kit.
The JDK is the primary package developers install to develop Java applications.
The javac compiler converts Java source code into bytecode.
The java launcher starts Java applications on the JVM.
Javadoc generates documentation from Java source comments.
The jar tool packages Java classes and resources into JAR archives.
JShell provides an interactive environment for experimenting with Java.
JDB provides command-line debugging capabilities.
Jlink can create a custom runtime image containing the modules an application needs.
For modern Java development, installing a JDK is generally the normal approach.
Conclusion
The JDK is the complete development toolkit for Java. It provides the compiler and a collection of tools that developers need to create, test, debug, document, package, and run Java applications. The most important tool to remember when starting Java is javac. It converts Java source code into bytecode, which can then be executed by the JVM. Once the role of the JDK is clear, understanding the other two parts of the Java ecosystem becomes much easier. The next article can focus specifically on the JRE (Java Runtime Environment) and explain what is required to run a Java application.