Scala Environment Setup – Install Java Development Kit (JDK)

By Nadim Bahadoor | Last updated: January 24, 2020 at 7:55 am

Overview

In this tutorial, we will go over how to install the Java Development Kit, also known as the JDK. As a reminder, with the license agreement changes for the OracleJDK, you may also consider using the open-source OpenJDK instead. You can find detailed instructions for installing an OpenJDK version here.

 

Steps

1. Verify JDK is installed

On a Mac:

If you are using a Mac, you may already have the JDK installed. To confirm, open a terminal window by clicking on the terminal icon:

 

mac_terminal_circle

 

If you do not have a terminal icon as shown above, click on the search icon in the top right corner of the Mac menu bar in order to open the Spotlight search:

 

search_terminal

 

In the Spotlight search textbox, type in Terminal and then hit enter to open it:

 

terminal_spotlight

 

Next, to confirm that you have Java already installed, type the following command in the terminal window: java -version

 

jdk_circle

 

If you see a Java version printed on the screen, you've already got the runtime! You can now skip the rest of this tutorial and move on to the next tutorial: Install IntelliJ IDE.

 

On Windows:

Open a Command Prompt window by going to the Windows Start menu and type in cmd in the search box. This will bring up a list of matching items and click or press enter on the Command Prompt item as shown below:

 

install_jdk_windows_1_1

 

This will then open up the Windows Command Prompt as follows:

 

install_jdk_windows_2

 

Next, to confirm that you have the JDK already installed on your Windows computer, type in the following command in the Windows Command Prompt window: java -version

 

install_jdk_windows_10

 

If you see a Java version printed on the screen, you've already got the runtime! You can now skip the rest of this tutorial and move on to the next tutorial: Install IntelliJ IDE.

 

If instead, you do not have a JDK installed, you will need to check if your Windows operating system is running a 32 bit or 64 bit version. From the Windows Start menu, select Settings and then the About menu:

install_jdk_windows_4

NOTE:

  • If you are running an older version of Windows, you can follow the instructions from this link to check the bit version of your operating system.

2. Install JDK on Mac
If you don't have a JDK installed, proceed to the Oracle website to download the JDK installer

 

jdk_url_circle

 

Note:

  • At the time of this tutorial, the latest JDK is version 8, commonly known as JDK 8 for short.

Click Accept license agreement and then select Mac OS X to start the download:

 

download_jdk_mac_circle
When the download is completed, you can find the installation file for the JDK 8 in the Downloads section of Finder:

 

jdk_download_file

 

Double click on the installation file which in our case is jdk-8u71-macosx-x64.dmg. Then double click on the package icon to start the installation:

 

jdk8_installation_icon

 

This opens the installation window and click Continue button:

 

jdk_install_continue

 

Notice it skips the install location because the destination folder on the Mac is pre-configured. Next click on the Install button:

 

jdk_install_button

 

On the Mac, you will need to enter your password and then press the Install Software button:

 

jdk_install_pwd

 

When the installation is completed, you will see a successful message displayed. Click the Close button to close the installation window.

 

jdk_install_success

 

Verify that you now have a Java runtime by following Step 1 above.

 

3. Install JDK on Windows
If you don't have a JDK installed, proceed to the Oracle website to download the JDK installer.

 

install_jdk_windows_3

 

Note:

  • At the time of this tutorial, the latest JDK is version 8, commonly known as JDK 8 for short.

Click on the Accept license agreement.

 

At this point, you will need to know if you are running a Windows 32 or 64 bit Operating System. If you do not know this information, please go back to Step 1 above which outlines how to check the bit version of your Windows Operating System.
Next, click on your corresponding Windows x86 (for 32 bit Operating System) or Windows x64 (for 64 bit Operating System) to start the download.

 

When the download is completed, click on the Run button to start the installation:

 

install_jdk_windows_5

 

This opens the installation wizard and click on the Next button:

 

install_jdk_windows_6

 

The following screen will show the default location for the JDK, and click on the Next button:

 

install_jdk_windows_7

 

This will kick off the installation as follows:

 

install_jdk_windows_8

 

When the installation is completed, you will see a successful message displayed. Click on the Close button to close the installation wizard.

 

install_jdk_windows_9

 

This concludes our tutorial on Scala Environment Setup - Install Java Development Kit (JDK) and I hope you've found it useful!

 

Stay in touch via Facebook and Twitter for upcoming tutorials.

 

Don't forget to like and share this page :)

Summary

In this article, we went over the following:

  • How to verify you have JDK already installed.
  • How to install the JDK on Mac or Windows.

Tip

  • If your Mac has an older version of JDK and you would like to update it to the latest version which at the time of this tutorial  is JDK 8, check out this tutorial from Oracle.

Source Code

The source code is available on the allaboutscala GitHub repository.

 

What's Next

In the next tutorial, I will go over how to install the IntelliJ Integrated Development Environment to help us write and execute our Scala code.

 

Stay tuned!

Nadim Bahadoor on FacebookNadim Bahadoor on GithubNadim Bahadoor on LinkedinNadim Bahadoor on Twitter
Nadim Bahadoor
Technology and Finance Consultant with over 14 years of hands-on experience building large scale systems in the Financial (Electronic Trading Platforms), Risk, Insurance and Life Science sectors. I am self-driven and passionate about Finance, Distributed Systems, Functional Programming, Big Data, Semantic Data (Graph) and Machine Learning.
Other allaboutscala.com tutorials you may like: