For working professionals
For fresh graduates
More
6. JDK in Java
7. C++ Vs Java
16. Java If-else
18. Loops in Java
20. For Loop in Java
46. Packages in Java
53. Java Collection
56. Generics In Java
57. Java Interfaces
60. Streams in Java
63. Thread in Java
67. Deadlock in Java
74. Applet in Java
75. Java Swing
76. Java Frameworks
78. JUnit Testing
81. Jar file in Java
82. Java Clean Code
86. Java 8 features
87. String in Java
93. HashMap in Java
98. Enum in Java
101. Hashcode in Java
105. Linked List in Java
109. Array Length in Java
111. Split in java
112. Map In Java
115. HashSet in Java
118. DateFormat in Java
121. Java List Size
122. Java APIs
128. Identifiers in Java
130. Set in Java
132. Try Catch in Java
133. Bubble Sort in Java
135. Queue in Java
142. Jagged Array in Java
144. Java String Format
145. Replace in Java
146. charAt() in Java
147. CompareTo in Java
151. parseInt in Java
153. Abstraction in Java
154. String Input in Java
156. instanceof in Java
157. Math Floor in Java
158. Selection Sort Java
159. int to char in Java
164. Deque in Java
172. Trim in Java
173. RxJava
174. Recursion in Java
175. HashSet Java
177. Square Root in Java
190. Javafx
The Java Development Kit (JDK) is the foundation of Java programming, providing all the tools, executables, and binaries needed to develop, compile, and run Java applications.If you're wondering "what is JDK in Java," it's essentially a software development environment that contains everything you need to develop Java-based applications. This guide explains JDK, its relationship with JRE and JVM, and provides practical examples of how to install and use JDK across different operating systems.
Turn your Java passion into a profession with upGrad’s expert-led, practical software engineering program.
The Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE), an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and other tools needed for Java development.
The JDK enables developers to create Java programs that can be executed by the Java Virtual Machine (JVM). It serves as the primary platform for Java development, providing all the necessary tools to develop, compile, debug, and run Java applications.
Upgrade your skills with these high-impact tech programs:
• Full Stack Development Bootcamp – upGrad
• AI Full Stack Development – IIIT Bangalore
• Master of Design in User Experience by Jindal Global School
The JDK includes several key components:
Also read: Exploring Java Architecture: A Guide to Java's Core, JVM and JDK Architecture
Let's examine what is JDK in Java with a simple example:
// HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World! This is a JDK example.");
}
Expected Output
Demonstrating JDK Features: JDK includes: Compiler (javac), Launcher (java), Archiver (jar), Documentation Generator (javadoc)
System Properties: Java Version: 17.0.2 Java Home: /usr/lib/jvm/java-17-openjdk OS Name: Linux
Accessing Compiler API: Java Compiler is available in this JDK
Using Java NIO (part of JDK): Current directory: /home/user/java-projects
Explanation:
This example demonstrates multiple JDK features including:
1. Core libraries for collections and streams
2. Access to system properties provided by the JRE within the JDK
3. The Compiler API which is available only in the JDK (not in the JRE)
4. File operations using Java NIO libraries
Also read: How to Install Java in Windows 10
The JDK, JRE, and JVM form a three-layer architecture that enables Java's "write once, run anywhere" capability. Let's explore how they work together:
- Development tools for creating, compiling, and debugging Java code
- Includes JRE and additional development utilities
- Provides the development ecosystem for Java programmers
- Provides runtime libraries needed to execute Java applications
- Contains class libraries, JVM, and support files
- End-users only need JRE to run Java applications
- Executes bytecode and provides memory management
- Handles platform-specific operations
- Makes Java platform-independent
The workflow from code to execution follows these steps:
1. Development: Write Java code using JDK tools
2. Compilation: JDK's compiler (javac) compiles source code (.java) to bytecode (.class)
3. Distribution: Package application (often in JAR files)
4. Runtime: JRE loads the application
5. Execution: JVM interprets/executes the bytecode
Let's illustrate this with a simple example:
// JDKWorkflowExample.java
public class JDKWorkflowExample {
public static void main(String[] args) {
System.out.println("Step 1: Developer writes this Java code using an IDE or text editor (part of JDK)");
// The compiled bytecode (JDKWorkflowExample.class) is created by javac (part of JDK)
System.out.println("Step 2: JDK's javac compiler converts this source code to bytecode");
// The application is run with 'java JDKWorkflowExample'
System.out.println("Step 3: JRE provides runtime environment for execution");
// The bytecode is executed by the JVM
System.out.println("Step 4: JVM executes the bytecode instructions");
// Demonstrate platform independence
System.out.println("Running on: " + System.getProperty("os.name") +
" " + System.getProperty("os.arch"));
}
}
Expected Output:
Step 1: Developer writes this Java code using an IDE or text editor (part of JDK)
Step 2: JDK's javac compiler converts this source code to bytecode
Step 3: JRE provides runtime environment for execution
Step 4: JVM executes the bytecode instructions
Running on: Windows 10 amd64
Explanation: This example demonstrates the entire workflow from code writing to execution, highlighting the roles of JDK, JRE, and JVM at each step.
Checkout: Jar file in Java
This guide has covered the essential aspects of Java's development environment, from installation across different operating systems to understanding the complex relationship between JDK, JRE, and JVM. As you continue your journey in Java development, remember that the JDK is your primary toolkit for bringing Java applications to life.
To compile and run this program, you would use the JDK's tools:
# Compile the Java source file using javac (JDK compiler)
javac HelloWorld.java
# Run the compiled bytecode using java (JDK launcher)
java HelloWorld
Expected Output:
Hello, World! This is a JDK example.
Explanation: The JDK's javac compiler converts the Java source code into bytecode (HelloWorld.class), and then the java launcher executes this bytecode using the JVM included in the JDK.
Must Explore: Packages in Java
Given below is a relationship between the three:
Understanding JVM JDK JRE in Java is crucial for Java developers. Let's see how they interact in practice:
// Class to demonstrate JDK, JRE, and JVM interaction
public class JavaComponentsDemo {
public static void main(String[] args) {
// JDK: Used to compile this code with javac
// JRE: Provides the runtime environment to run this program
// JVM: Executes this code and manages memory
// Get JRE version
String jreVersion = System.getProperty("java.version");
System.out.println("JRE Version: " + jreVersion);
// Get JVM name
String jvmName = System.getProperty("java.vm.name");
System.out.println("JVM Name: " + jvmName);
// Get class path (set by the JRE)
String classPath = System.getProperty("java.class.path");
System.out.println("Class Path: " + classPath);
}
}
Expected Output:
JRE Version: 17.0.2
JVM Name: OpenJDK 64-Bit Server VM
Class Path: .
Explanation: This program demonstrates how JDK, JRE, and JVM work together:
Installing the JDK is the first step to start Java development. Let's look at the installation process for windows.
Installing JDK in Windows 10 involves the following steps:
1. Download the JDK installer from Oracle's website or adopt OpenJDK
2. Run the installer and follow the installation wizard
3. Set up JAVA_HOME environment variable
4. Add JDK bin directory to the PATH environment variable
5. Verify the installation
Here's a more detailed guide:
Verify Installation: Open Command Prompt and type: java -version
javac -version
To better understand what the JDK does, let's create a more comprehensive example that demonstrates some key JDK functionalities:
// JDKFeaturesDemo.java
import java.util.List;
import java.util.ArrayList;
import java.util.stream.Collectors;
import javax.tools.*;
import java.io.File;
import java.nio.file.*;
public class JDKFeaturesDemo {
public static void main(String[] args) {
System.out.println("Demonstrating JDK Features:");
// 1. Using core libraries (part of JDK)
List<String> jdkComponents = new ArrayList<>();
jdkComponents.add("Compiler (javac)");
jdkComponents.add("Launcher (java)");
jdkComponents.add("Archiver (jar)");
jdkComponents.add("Documentation Generator (javadoc)");
// Using streams API (introduced in Java 8)
String components = jdkComponents.stream()
.collect(Collectors.joining(", "));
System.out.println("JDK includes: " + components);
// 2. Accessing system properties (provided by JRE within JDK)
System.out.println("\nSystem Properties:");
System.out.println("Java Version: " + System.getProperty("java.version"));
System.out.println("Java Home: " + System.getProperty("java.home"));
System.out.println("OS Name: " + System.getProperty("os.name"));
// 3. Using compiler API (a JDK tool)
try {
System.out.println("\nAccessing Compiler API:");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler != null) {
System.out.println("Java Compiler is available in this JDK");
} else {
System.out.println("Java Compiler is not available (you might be using JRE only)");
}
// 4. File operations using NIO (part of JDK)
System.out.println("\nUsing Java NIO (part of JDK):");
Path currentPath = Paths.get(".");
System.out.println("Current directory: " + currentPath.toAbsolutePath().normalize());
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
The Java Development Kit (JDK) is the cornerstone of Java development, providing all the tools needed to create, compile, and run Java applications. Understanding the differences between JDK, JRE, and JVM is crucial for both developers and users of Java applications.
With JDK, developers can harness the full power of Java's "write once, run anywhere" philosophy, creating applications that can run on any platform with a JVM. Whether you're developing a small utility or enterprise-level software, the JDK provides the foundation you need to build cross-platform Java applications.
The JDK (Java Development Kit) is a complete development package containing JRE plus development tools like compilers and debuggers. The JRE (Java Runtime Environment) is a subset of JDK that provides libraries and resources to run Java applications. The JVM (Java Virtual Machine) is a component of both JDK and JRE that executes Java bytecode and provides memory management.
JDK is used for developing, compiling, debugging, and running Java applications. It provides the essential tools, executables, and binaries that developers need throughout the Java application development lifecycle, from writing code to testing and deployment.
End-users only need the JRE to run Java applications as it contains the necessary runtime libraries and JVM. Developers need the JDK to create and compile Java programs. If you're only running Java applications and not developing them, JRE is sufficient.
The main components of JDK include development tools (javac compiler, java launcher, jar archiver, javadoc documentation tool), the Java Runtime Environment (JRE), additional libraries, and the Java Virtual Machine (JVM).
The choice of JDK depends on your project requirements. For long-term support, consider using LTS (Long Term Support) versions like JDK 8, 11, or 17. For cutting-edge features, use the latest version. Consider OpenJDK for open-source projects or Oracle JDK for commercial use (note Oracle's licensing changes after JDK 8).
You can check your JDK version by opening a command prompt or terminal and typing java -version (for runtime version) and javac -version (for compiler version). This will display the version information of your installed Java.
Yes, you can have multiple JDK versions installed on the same system. Tools like SDKMAN (Linux/macOS) or JEnv can help manage multiple Java versions and switch between them as needed. On Windows, you can manually modify the PATH and JAVA_HOME environment variables.
Oracle JDK and OpenJDK are implementations of the Java Platform Standard Edition. OpenJDK is the open-source reference implementation, while Oracle JDK is Oracle's commercial distribution based on OpenJDK. Since JDK 11, Oracle JDK requires a commercial license for production use, while OpenJDK remains free and open source.
On Windows, set JAVA_HOME through System Properties > Environment Variables. On Linux/macOS, add export JAVA_HOME=/path/to/jdk to your shell configuration file (.bashrc, .zshrc, etc.). The JAVA_HOME variable should point to the JDK installation directory.
JDK 8 introduced lambda expressions and the Stream API. JDK 11 introduced the HTTP Client API, local variable type inference with var, and removed some deprecated components. JDK 17 added sealed classes, pattern matching for switch, and improved random number generators. Each version also includes performance improvements and security updates.
OpenJDK is free and open-source for both personal and commercial use. Oracle JDK is free for development and testing but requires a paid license for commercial deployment since Java 11. AdoptOpenJDK (now Eclipse Temurin) provides free, production-ready OpenJDK builds.
Take the Free Quiz on Java
Answer quick questions and assess your Java knowledge
Author|900 articles published
Previous
Next
Talk to our experts. We are available 7 days a week, 9 AM to 12 AM (midnight)
Indian Nationals
1800 210 2020
Foreign Nationals
+918068792934
1.The above statistics depend on various factors and individual results may vary. Past performance is no guarantee of future results.
2.The student assumes full responsibility for all expenses associated with visas, travel, & related costs. upGrad does not provide any a.