What is the difference between JDK and JRE?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
The Java Development Kit (JDK) and the Java Runtime Environment (JRE) are two crucial components of the Java ecosystem, essential for developing and running Java applications. However, they serve different purposes and contain different tools and libraries necessary for Java developers and users. Understanding the distinction between JDK and JRE is fundamental for anyone involved in Java application development or deployment.
Understanding the Java Runtime Environment (JRE)
The JRE is a software package that provides the libraries, the Java Virtual Machine (JVM), and other components necessary for running applications written in the Java programming language. When you want to run a Java program and do not intend to develop one, the JRE is what you need. It essentially acts as a runtime library for Java applications.
The JVM is a critical part of the JRE and is responsible for converting Java bytecode into machine code. When a program is written in Java, it is compiled by the JDK into a platform-independent bytecode. This bytecode is then interpreted or compiled into native machine code at runtime by the JVM.
Understanding the Java Development Kit (JDK)
The JDK includes everything that is in the JRE, but it also contains an additional set of tools necessary for developing Java applications, such as a compiler (javac), JavaDoc, debugger, and various other developer tools. Thus, the JDK is a superset of the JRE.
The primary component of JDK is the Java compiler (javac), which is used to convert Java code into bytecode. This bytecode is platform-independent and can be executed on any machine that has a compatible JVM, which is provided by the JRE. The JDK also comes with tools for monitoring, debugging, and documenting your Java applications.
Key Differences
| Feature | JDK | JRE |
| Purpose | To develop Java applications | To run Java applications |
| Contains | JRE, compiler, and developer tools such as debugger, JavaDoc, etc. | JVM, platform libraries, and other components needed to run Java applications |
| Used by | Developers | End-users who only need to run Java applications |
Additional Components in JDK
Beyond the compiler and the JRE, the JDK provides several other development tools:
- JavaDoc: This tool is used to generate API documentation in HTML format from Java source code.
- Java Debugger (JDB): A command-line tool for finding bugs in Java programs.
- JavaFX: Included in newer versions of JDK to develop and deploy rich Internet applications.
- Monitoring and Performance Tools: Tools like VisualVM and JConsole can monitor, manage, and profile Java applications.
Practical Examples
- Developers setting up a development environment need JDK because they compile Java applications, whereas a consumer who just wants to run Java apps (like a Java-based game) would need only the JRE.
- When you execute the
java -versioncommand, it will show whether your system has JRE or JDK installed and its version number. To compile a Java program, one would use thejavaccommand, which is available only in JDK.
Conclusion
In conclusion, while both JDK and JRE are intertwined and their roles overlap, the primary difference lies in their use cases. JDK is used for developing Java applications, providing both the runtime environment and the development tools necessary. On the other hand, JRE is sufficient for users who are only interested in running Java applications and do not need development tools.
Understanding this can help in properly setting up systems, whether it’s for developing Java applications or simply running them.
Related reading
- What is the difference between JDK dynamic proxy and CGLib?
- What is the difference between JSF, Servlet and JSP?
- What is the difference between JVM, JDK, JRE & OpenJDK?
- What is the difference between List.of and Arrays.asList?
- What is the difference between MANUAL and MANUAL_IMMEDIATE in spring-kafka AckMode
- What is the difference between mocking and spying when using Mockito?
- What is the difference between Optional.flatMap and Optional.map?
- What is the difference between pom type dependency with scope import and without import?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.