The Java Development Kit (JDK) is a versatile software development environment that provides tools and libraries for creating Java-based software applications and applets. It plays a central role in the Java ecosystem, working alongside the JVM (Java Virtual Machine) and the JRE (Java Runtime Environment).
For newcomers, distinguishing between JRE and JDK can be confusing. If you aim solely to run Java programs on your computer, you can achieve that using the Java Runtime Environment (JRE). However, if you aspire to develop Java-based software applications, you’ll require more than just the JRE. In this case, you’ll need the JDK, which includes the essential tools for development.
Recommended CourseÂ
- Â Decode DSA with C++
- Full Stack Data Science Pro CourseÂ
- Java For Cloud CourseÂ
- Full Stack Web Development Course
- Data Analytics CourseÂ
We can say that.: JDK = JRE + Development tools
The JDK (Java Development Kit) includes several important components:
Java Runtime Environment (JRE): This is like a mini Java environment that allows you to run Java applications.
Interpreter/Loader (Java): This component helps load and execute Java programs.
Compiler (javac): It translates your Java code into a format the computer can understand.
Archiver (jar): This tool packages multiple files into one archive file, often used for distributing Java applications.
In the JDK, the Java Runtime Environment is often called the “Private Runtime” because it differs slightly from the regular JRE. It includes a Java Virtual Machine (JVM) and all the class libraries found in the production environment. JDK contains extra libraries for developers, such as those for internationalization and IDL.
Here are some of the most popular JDKs:
Oracle JDK: This is the most widely used JDK and is the primary source for Java 11.
OpenJDK: It’s ready for use and includes versions like JDK 15, JDK 14, and JMC (Java Mission Control).
Azul Systems Zing: Known for its efficiency and low latency, it’s designed for Linux operating systems.
Azul Systems Zulu: This is based on the Zulu brand and works on Linux, Windows, and macOS.
IBM J9 JDK: It’s designed for AIX, Linux, Windows, and other operating systems.
Amazon Corretto: This newer option offers a no-cost build of OpenJDK with long-term support.
Setting up the JDK in your development environment is quite straightforward. Here are the steps:
Installation of JDK:
Visit Oracle’s official Download Page via this link.
Choose the latest JDK version, click Download, and add it to your classpath.
Ensure the JDK software is correctly installed on your computer, typically in a location like C:\Program Files\Java\jdk11.0.9.
Setting JAVA_HOME for Windows:
Right-click on My Computer and select Properties.
Go to the Advanced tab, then select Environment Variables.
Edit JAVA_HOME to point to where your JDK software is stored. For example, C:\Program Files\Java\jdk11.0.9 is the default location in Windows.
Java maintains all backward compatibility, so you don’t have to worry. Download the latest release, and you’ll get access to all the old and many new features. After installing the JDK and JRE, you can use the java command in your command line. You can verify the installation by running the java -version command. Sometimes, you may need to restart your system after installing the JDK.
Compile and Run JAVA code using JDK.
You can use the JDK compiler to turn your Java text file into a program your computer can run. When you compile your Java code, it’s transformed into something called bytecode and gets a file extension of .class.
Here’s how you can do it:
First, make a Java text file and give it a name. For example, let’s call it Hello.java.
Next, use the Javac command to compile it. This command is used to convert your code into a runnable program. But be sure to provide the full path to your Java text file in the command. If you don’t, you’ll get an error message like “The system cannot find the path specified.” Here’s an example of what your command should look like:
After you run the command, you’ll notice a file named Hello.class appears in the same directory where your Hello.java file is located.
Now, you can run your Java code by using the following command:
java Hello
This command will execute your program and give you the results based on the code you wrote. One important thing to remember is that you don’t need to include the .class extension when running your code.
Important Components of JDK
To make Java development possible, different components work together synchronously. You start by writing your code and then compile it using Javac. Afterward, you may package it with the jar, if needed, and run it using the Java interpreter. It’s like having the necessary tools to build and execute Java software.
Component | Use |
---|---|
javac | Â Java compiler converts source code into Java bytecode |
java | Â The loader of the java apps. |
javap | Â Class file disassembler, |
javadoc | Â Documentation generator, |
jar | Â Java Archiver helps manage JAR files. |
appletviewer | Â Debugging of Java applets without a web browser, |
xjc | Â Accepts an XML schema and generates Java classes, |
apt | Â Annotation-processing tool, |
jdb | Â Debugger, |
jmc | Â Java Mission Control, |
JConsole | Â Monitoring and Management Console, |
pack200 | Â JAR compression tool, |
extcheck | Â Utility tool to detects JAR file conflicts, |
idlj | Â IDL-to-Java compiler, |
keytool | Â The keystore manipulating tool, |
jstatd | Â jstat daemon (experimental) |
jstat | Â JVM statistics monitoring tool |
jshell | Â jshell introduced in java 9. |
jstack | Â Prints Java stack traces(experimental) |
jrunscript | Â Java command-line script shell. |
jhat | Â Java Heap Analysis Tool (experimental) |
jpackage | Â Generate self-contained application bundles. |
javaws | Â Web Start launcher for JNLP applications, |
javah | Â C header and stub generator, |
jarsigner | Â jar signing and verification tool |
jinfo | configuration information(experimental) |
javafxpackager | Package and sign JavaFX applications |
Recommended Reads
- Data Science Certification CourseÂ
- Data Science Interview Question and Answer
- The Future of Data Science Courses in India
- Top 15 Data Science Books Read in 2023
- Data Science Course in IndiaÂ
JDK in JAVA FAQs
What do you mean JDK JRE and JVM in Java?
Ans. The JDK's an abbreviation of the Java Development Kit. The JRE is a Java Runtime Environment abbreviation. Java Virtual Machine is an abbreviation for Java Virtual Machine. Definition. The JDK Development Kit is a programming tool for developing applications in Java.
How does JDK work?
Ans. The Java Development Kit is called the JDK. The JDK makes it possible to create a Java application, as the name implies. It will convert your Java source code to a format which can be understood by JRE and JVM. It's got a debugger, which tells us if we have an error trying to compile our code.
Is JDK only used in JAVA?
Ans. The SDK is the complete Java development kit that comes with JRE and necessary tools. If you only need to run Java programs, install JRE instead.
What is the difference between IDE and JDK?
Ans. JDK has Java program compilation and running tools, while an IDE assists in coding.