“`html
The Java Development Kit (JDK) is one of three core technology packages used in Java programming, along with the JVM (Java Virtual Machine) and the JRE (Java Runtime Environment). It’s important to differentiate between these three technologies and understand how they’re connected: The JVM is the runtime that hosts running programs. The JRE is the on-disk part of Java that creates the JVM and loads programs into them. The JDK provides the tools necessary to write Java programs that can be executed and run by the JVM and JRE. Developers new to Java often confuse the Java Development Kit and the Java Runtime Environment. The distinction is that the JDK is a package of tools for developing Java-based software, whereas the JRE is a package of tools for running Java code. The JRE can be used as a standalone component to simply run Java programs, but it’s also part of the JDK. The JDK requires a JRE because running Java programs is part of developing them.
Before we move on, let’s consider the technical and everyday definitions of the JDK:
- Technical definition: The JDK is an implementation of the Java platform specification, which includes the compiler and standard class libraries.
- Everyday definition: The JDK is a software package you download in order to create Java-based applications.
JDK versions and packages
Getting Java set up in your development environment is as easy as downloading a JDK and adding it to the system path on your operating system. For Windows and macOS, Java includes an installer that will do this for you. When you download your JDK, you will need to select the version of Java you want to use. Java 11 has surpassed Java 8 as the most commonly used version. Looking ahead, it seems that Java 17 may be the next prominent version. Java maintains backward compatibility, so we’ll just download the latest release. In the past, you also had to select a Java package. There are JDKs targeted for different types of development like Java Enterprise Edition (Java EE), Java Standard Edition (Java SE), and Java Mobile Edition (Java ME). Now that the enterprise Java libraries have migrated to Jakarta EE, you will still download the Java SE JDK from an implementer like Oracle or OpenJDK. If you need additional tools useful for enterprise and cloud-native application development, then you will likely want to download and install Jakarta EE.
Download the JDK for Java SE
We’ll stick with Java SE for this introduction so that we can focus on the core JDK classes and technologies. To download the Java SE development kit, visit Oracle’s official download page. You’ll see the various JDK packages available.
How to install the JDK
There are two flavors of JDK installation: manual or installer. In a manual install, you download the binaries, extract them, and add them to the path. You probably know how to perform this type of installation. Installers are available for macOS and Windows. When you run a JDK installer, you’ll be given a selection of three components: Development Tools, Source Code, and Public JRE. You may install one or all of them.
Installing the Development Tools option gives you the JDK proper. Installing Source Code contains the sources for the public classes in the core Java API. Including this option allows you to reference the source code when building applications. The third option, Public JRE, drives home that the JDK and JRE are separate entities.
Two key Java commands: java and javac
The JRE inside your JDK adds the java command to your command line. You can verify this by dropping into a command shell and typing java -version, which should return the Java version you’ve just installed. (In some cases you’ll have to restart your system for this change to your system path to fully take.)It’s good to have java installed, but what about javac? You’ll need this JDK component to compile your Java files. The javac command lives inside the /jdk directory, and in recent versions of the installer will automatically be added to the path. Some IDEs include a Java compiler by default. It is usually possible to configure them to use a specific installed version if you wish.
“`