What is the Java Development Kit (JDK)? A Complete Info 18.0.2.0
The Java Development Kit (JDK) is a set of tools and libraries that can be used to make Java-based software applications and applets. It is a software development environment that works on multiple platforms. It is a core package for Java, like the JVM (Java Virtual Machine) and the JRE (Java Runtime Environment).
People who are just starting out often get JRE and JDK mixed up. If all you want to do is run Java programmes on your computer, you can do that easily with Java Runtime Environment. But if you want to make a Java-based software application, you may need more tools than just JRE. This set of tools is called JDK.
What is JDK: Java Development Kit
The Java Development Kit (JDK) is a software development environment that is used to make Java applications and applets. It exists in the real world. It has JRE and tools for developing.
- Standard Edition Java Platform
- Enterprise Edition Java Platform
- Micro Edition Java Platform
The JDK has a private Java Virtual Machine (JVM) and a few other resources, like an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), etc., that are needed to develop a Java application.
Developers who are just getting started with Java often get the Java Development Kit and the Java Runtime Environment mixed up. The JDK is a collection of tools for making Java-based software, while the JRE is a collection of tools for running Java code.
The JVM (Java Virtual Machine) and the JRE (Java Runtime Environment) are the other two core technology packages used in Java programing (Java Runtime Environment). It’s important to know how these three technologies are different from each other and how they work together:
- The JVM is the host for programs that are running.
- The JRE is the part of Java that is stored on your hard drive. It is what makes the JVM and loads programs into it.
- The JDK gives you the tools you need to write Java programs that the JVM and the JRE can run.
The JRE can be used by itself to run Java programs, or it can be used as a part of the JDK. Because running Java programs is part of making them, the JDK needs a JRE.
Before we look further ahead, let’s try to know, what the JDK means in both technical and everyday terms:
- Technically, the JDK is an implementation of the Java platform specification. It includes the compiler and standard class libraries.
- In the general concept, The JDK is a set of software that you can download to make Java-based apps.
Java Development Kit (JDK) Components
Here is a list of the most important components of JDK:
appletviewer: | This tool is used to run and debug Java applets without a web browser. |
apt: | It is an annotation-processing tool. |
extcheck: | it is a utility that detects JAR file conflicts. |
idlj: | An IDL-to-Java compiler. This utility generates Java bindings from a given Java IDL file. |
jabswitch: | It is a Java Access Bridge. Exposes assistive technologies on Microsoft Windows systems. |
java: | The loader for Java applications. This tool is an interpreter and can interpret the class files generated by the javac compiler. Now a single launcher is used for both development and deployment. The old deployment launcher, jre, no longer comes with Sun JDK, and instead it has been replaced by this new java loader. |
javac: | It specifies the Java compiler, which converts source code into Java bytecode. |
javadoc: | The documentation generator, which automatically generates documentation from source code comments |
jar: | The specifies the archiver, which packages related class libraries into a single JAR file. This tool also helps manage JAR files. |
javafxpackager: | It is a tool to package and sign JavaFX applications. |
jarsigner: | the jar signing and verification tool. |
javah: | the C header and stub generator, used to write native methods. |
javap: | the class file disassembler. |
javaws: | the Java Web Start launcher for JNLP applications. |
JConsole: | Java Monitoring and Management Console. |
jdb: | the debugger. |
jhat: | Java Heap Analysis Tool (experimental). |
jinfo: | This utility gets configuration information from a running Java process or crash dump. |
jmap: | Oracle jmap – Memory Map- This utility outputs the memory map for Java and can print shared object memory maps or heap memory details of a given process or core dump. |
jmc: | Java Mission Control |
jps: | Java Virtual Machine Process Status Tool lists the instrumented HotSpot Java Virtual Machines (JVMs) on the target system. |
jrunscript: | Java command-line script shell. |
jstack: | It is a utility that prints Java stack traces of Java threads (experimental). |
jstat: | Java Virtual Machine statistics monitoring tool (experimental). |
jstatd: | jstat daemon (experimental). |
keytool: | It is a tool for manipulating the keystore. |
pack200: | JAR compression tool. |
Policytool: | It specifies the policy creation and management tool, which can determine policy for a Java runtime, specifying which permissions are available for code from various sources. |
VisualVM: | It is a visual tool integrating several command-line JDK tools and lightweight [clarification needed] performance and memory profiling capabilities |
wsimport: | It generates portable JAX-WS artifacts for invoking a web service. |
xjc: | It is the part of the Java API for XML Binding (JAXB) API. It accepts an XML schema and generates Java classes. |
| The JDK and the Java compiler
Every JDK has a Java compiler as well as the JRE, which is the environment used to run Java applications. The compiler is a piece of software that can turn raw.java files, which are just plain text, into.class files that can be run. Soon, we’ll see how the compiler works. First, I’ll show you how to set up a JDK in your development environment and how to download it.
Versions and packages of the JDK
You can set up Java in your development environment by downloading a JDK and adding it to your operating system’s system path. Java comes with an installer for both Windows and macOS that will do this for you.
When you download your JDK, you will need to choose which version of Java you want to use. The most popular version of Java is now Java 11, which just barely beat out Java 8. If you look into the future, it seems like Java 17 could be the next big version. Java stays compatible with older versions, so we’ll just get the latest one.
You also had to choose a Java package in the past. These JDKs were made for different kinds of development, like Java Enterprise Edition (Java EE), Java Standard Edition (Java SE), and Java Mobile Edition (Java ME). The process has changed now that the enterprise Java libraries have moved to Jakarta EE. You will still get the Java SE JDK from a developer, such as Oracle or OpenJDK. Downloading and installing Jakarta EE is probably a good idea if you need more tools for building enterprise and cloud-native apps. You might not always need the whole Jakarta EE platform. For example, if you only needed a JDK and servlets, you could use the standard JDK and Tomcat, which includes the Servlet API.
| JDK versions Compatibility
Since the JDK gives you the compiler for your Java programs, the version of Java you can code in depends on which JDK you use. For example, you need at least the Java 8 JDK to compile if you want to use functional programing features. If not, the lambda code will be rejected by the javac command because of a syntax error.
Download the JDK for Java SE Here
For this introduction, we’ll stick to Java SE so that we can focus on the core JDK classes and technologies. Visit Oracle’s official download page to find out how to get the Java SE development kit. Figure 2 shows the different JDK packages you can choose from.
Take a moment to look at the other options before you choose to download Java SE. A lot is going on in the Java kitchen.
| About Jakarta EE
The Eclipse Foundation is in charge of Jakarta EE, which now has all of Java’s enterprise and cloud-native features built in. You will always need a standard JDK to build Java apps. After that, you can choose which projects you want to include. Download the Java Standard Edition JDK from the Oracle website for now. OpenJDK is another popular choice.
Installation of the JDK
There are two ways to install JDK: manually or with an installer. In a manual installation, you download the binaries, extract them, and add them to the path. All operating systems are the same in this way. You probably already know how to set up this kind of thing.
There are installers for both macOS and Windows. When you run a JDK installer, you can choose from three parts: Development Tools, Source Code, and Public JRE. You can install any of them. In this case, you should just pick the default.
If you choose to install the Development Tools, you will get the JDK itself. The sources for the public classes in the core Java API are found in the Installing Source Code file. By choosing this option, you can build applications that use the source code. The third option, “Public JRE,” shows that the JDK and JRE are two different things. Other programs can use the public JRE to run Java programs, and it can be installed separately from the JDK.
Go ahead and install all three parts, leaving each one’s settings as they are. If you do this, your JDK and JRE will be installed where your operating system wants them to be. Figure 3 shows that on Windows, this is C:Program FilesJavajdk-*. (In older Java versions, the JDK and JRE were in different directories. In newer versions, they are both installed at the same time in the JDK directory.)
Two key Java commands: java and javac
The java command is added to your command line by the JRE that comes with your JDK. You can check this by opening a command shell and typing “java -version.” This should show you the version of Java you just installed. (In some cases, you’ll have to restart your system for this change to your system path to take effect.)
Installing Java is a good idea, but what about javac? To compile your Java files, you’ll need this part of the JDK.
The javac command is in the /jdk directory, and newer versions of the installer add it to the path automatically. Some IDEs come with a Java compiler already installed. Most of the time, you can set them up to use a certain installed version if you want to.
Compile and run a Java program
First, we’ll use text files and console commands to compile and run a Java program the old-fashioned way. This helps us understand what’s really going on.
Step 1. Write a simple Java program
Make a new text file called Intro.java and put it somewhere on your computer, like the documents folder.
Next, add the code from Listing 1, which is a simple Java program.
Listing 1. Intro.java
Step 2. Compile with the JDK
The next step is to use the JDK compiler to turn your text file into a program that can be run. Java code that has been compiled is called bytecode and carriers the
.class
extension.
You will use the javac command and give it the file Intro.java as its argument. You use the javac command to run the Java file we made in Listing 1. That looks like Listing 2 on my system. (In older versions of Java, you have to type the full path to the command into your command shell, as shown in the line with a comment.)
Listing 2. Compile with the JDK
That should make it possible to compile. The javac won’t tell you that it worked; it will just show you the new file. Any errors will show up on the console.
Step 3. Open the.class file
Now, the Intro.class file should be in the same directory as the Intro.java file.
You can run it by typing java Intro, which will give you the output shown in Listing 3. When you type this command, don’t type the .class at the end.
Listing 3. Run Intro.class
Create a JAR file and add it to your classpath.
The main tool in the JDK is javac, but you will also need other tools from the /bin directory. After javac, the jar tool is likely the most well-known.
A Java class set is stored in a JAR (.jar) file. Once the compiler has made the .class files, the developer can put them all in a.jar, which compresses and organises them in a predictable way.
Let’s turn the Intro.class file into a .jar file.
Go back to the directory where you put Intro.java and type the command shown in Listing 4.
Listing 4. Create a JAR file
Now, there’s a file called “intro.jar” in the directory. You can use the .jar by adding it to your classpath and running the program inside it, as shown here:
Listing 5. Put the JAR file on your classpath
Java is told to add the jar to the classpath by the –cp switch. A .jar file is more than we need for this small program, but they become more important as programs get bigger and depend on packages from other sources.
The JDK in your IDE
An integrated development environment (IDE) is a piece of software that gives you a set of tools that work together to make apps. Think of an IDE as a visual operating system with a file browser and a text editor, as well as features like code completion and formatting that are unique to development. Eclipse, IntelliJ, and NetBeans are all powerful Java IDEs that have been used for a long time. Visual Studio Code (VS Code), which is widely used and made by Microsoft, is another good option for developing Java apps.
One of the most important things the IDE does in Java development is take care of compilation. That is, the IDE runs the compile process automatically in the background so you don’t have to do it over and over again. An IDE also gives you feedback as you go, so you can catch coding mistakes as they happen.
You’ve seen how the JDK works on the command line. Now, let’s take a quick look at how it works in Eclipse.
Eclipse and the JDK
This guide doesn’t cover how to install Eclipse, but it’s easy to do. Like any other program, Eclipse has an installer, and you can find the one for your operating system here.
Once Eclipse is set up, go to the menu bar, click Window, and then click Preferences.
You’ll find the Java item in the Preferences window. When you open it, you’ll find the Compiler item inside. If you click that, you’ll see choices for the JDK.
As was already said, you will need to choose the right version of the JDK for your project. Under the hood, the IDE will run the JDK compiler the same way you ran it from the command line. There is also a JDK instance for the Eclipse IDE. The IDE takes care of the JDK and JRE for you, which is a big help.
Most Used JDKs:
- Oracle JDK: the most popular JDK and the main distributor of Java11,
- OpenJDK: Ready for use: JDK 15, JDK 14, and JMC,
- Azul Systems Zing: efficient and low latency JDK for Linux os,
- Azul Systems: based Zulu brand for Linux, Windows, Mac OS X,
- IBM J9 JDK: for AIX, Linux, Windows, and many other OS,
- Amazon Corretto: the newest option with the no-cost build of OpenJDK and long-term support.
Comments are closed.