Installing Java JDK

Written by PChan on 2017-05-13

Linux

Writing Java programs requires installing the Java JDK (Java Development Kit) while running Java programs would require you to install the Java JRE (Java Runtime). This guide would cover how to install the Java JDK.

  • Ubuntu/Mint/Debian

    sudo apt-get install openjdk-8-jdk openjdk-8-jre
    
  • Fedora

    su -c "yum install java-1.8.0-openjdk-devel java-1.8.0-openjdk"
    
  • Other Distros, you probably know how...

Note

The current version of this guide assumes you want to install Java 8. To install a different version of Java, simply replace the 8 in openjdk-8-jdk and the 8 in openjdk-8-jre for Debian system with the latest version of Java.

For Fedora, replace the 8 in java-1.8.0-openjdk-devel and the 8 in java-1.8.0-openjdk with the latest version of Java.

Mac OSX

Writing Java programs requires installing the Java JDK (Java Development Kit) while running Java programs would require you to install the Java JRE (Java Runtime). This guide would cover how to install the Java JDK.

We are going to be installing the Java JDK via Homebrew:

  1. Install Homebrew following the Installing Homebrew guide if it is not already installed (near the bottom, you will also find instructions for installing cask and brew-cask-upgrade)

  2. Install Java by executing the following command in the terminal:

    $ brew cask install java
    

Note: In the future, update Java with the following command:

$ brew update
$ brew cu

Windows

Writing Java programs requires installing the Java JDK (Java Development Kit) while running Java programs would require you to install the Java JRE (Java Runtime). This guide would cover how to install the Java JDK.

Download the JDK

  1. Go to Java SDK download site

  2. Under the heading: “Java Platform, Standard Edition”, click on the download button for JDK.

    ../../../_images/java-se-downloads.png

    The heading has been underlined in orange, while the download button for the JDK is circled in green.

Tip

To find out whether you are using x32 or x64 bit OS, check out this guide from Microsoft. To clarify, those with 32-bit operating system (as shown below) should download Oracle’s “Windows x86” Java. Those with 64-bit operating system should download Oracle’s “Windows x64” Java.

../../../_images/operating-system-type.png

The operating system type is underlined in orange. Ignore the processor type.

  1. The latest version of the Java JDK is found right underneath the description at the top. Accept the license agreement and download the appropriate version for your operating system.

    ../../../_images/java-jdk-download.png

    Make sure to accept the license agreement (in orange). The Windows download links are underlined in blue.

Warning

Note that the version number in the screenshot may differ from the ones you see.

  1. Run the executable that you just downloaded. It will install both the Java JDK and the Java JRE.
  2. Add the Java JRE and the Java JDK to your system path. If you are not sure how to do so...
    • Using Windows Explorer, navigate to C:\Program Files\Java where you will find a directory for the Java JDK and a directory for Java JRE.
    • Read the Modifying Windows Path guide and then add the following two folders to your path:
      • C:\Program Files\Java\<jdk_directory>\bin (<jdk_directory> is the name of the jdk directory)
      • C:\Program Files\Java\<jre_directory>\bin (<jre_directory> is the name of the jre directory)
  3. Close any open Command Prompt windows. Open a new Command Prompt window by pressing the Windows key, then typing cmd enter. Try the following commands: javac -version and java -version
  4. If you did not get a commmand not found error, congratulations!!!