Installing the Java development kit (JDK)

Updated: 3 years ago

Check out other lessons in Setting up your Java development environment

The Java development kit (JDK) is a package of tools for developing, debugging and monitoring Java applications. A working JDK is the first necessary step in learning Java, because you'll need it when running your Java code.

What is the JDK?

The Java development kit (JDK) is a collection of tools and resources that enable you to compile and run Java code. It's the necessary first step in building your own Java applications and is a very important tool in your arsenal. While you can write Java code without the JDK, you won't be able to compile and run it.

The JDK also includes a Java virtual machine (JVM), which is a piece of software that creates a virtual environment inside your computer. Every Java application then runs in that virtual environment. That's how you are able to run your Java applications on any platform because they are actually running inside a virtual machine and that virtual machine then talks to your computer.

You'll write Java code and then use the JDK to compile it. Compiling means taking your human-readable code and converting it to something that a machine can understand. Once you have machine readable code, you can run it inside the Java virtual machine.

Installing the JDK

The JDK can be downloaded from the Oracle's JDK downloads site. We are going to be installing the development kit for the Java 8 version, which is the latest version.

Download the JDK

Accept the license agreement, download and install the JDK for your platform.

Making sure that everything works

Open your command prompt or terminal. A terminal is a tool that helps you run console commands. On OS X, you could use Terminal, while Windows users could use Command prompt or PowerShell. Don't worry, these tools are already preinstalled on your OS, you just have to find them and open them.

Now write java -version into your terminal.

You should see the following:

 java version '1.8.0_60'     
 Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
 Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)


Now let's setup an IDE that will help you write Java code.

'java' is not recognized as an internal or external command, operable program or batch file.
  1. Make sure that you have successfully installed the Java development kit.
  2. Manually add the path to the JDK install location to your PATH.

The second step might be a bit overwhelming so here's a stackoverflow answer to help you along.

» Next lesson:
Installing an IDE