Scala Environment Setup – Install Java Development Kit (JDK)
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:
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:
In the Spotlight search textbox, type in Terminal and then hit enter to open it:
Next, to confirm that you have Java already installed, type the following command in the terminal window: java -version
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:
This will then open up the Windows Command Prompt as follows:
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
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:
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
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:
When the download is completed, you can find the installation file for the JDK 8 in the Downloads section of Finder:
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:
This opens the installation window and click Continue button:
Notice it skips the install location because the destination folder on the Mac is pre-configured. Next click on the Install button:
On the Mac, you will need to enter your password and then press the Install Software button:
When the installation is completed, you will see a successful message displayed. Click the Close button to close the installation window.
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.
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:
This opens the installation wizard and click on the Next button:
The following screen will show the default location for the JDK, and click on the Next button:
This will kick off the installation as follows:
When the installation is completed, you will see a successful message displayed. Click on the Close button to close the installation wizard.
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!