How to Install the JDK (Java Development Kit) on a Mac

Installing the Java Development Kit (JDK) on your Mac will allow you to write and compile Java applications. Installation of the JDK is very straightforward, and includes a development environment called NetBeans. You'll be using NetBeans...

Part 1 of 2:

Installing JDK

  • Picture 1 of How to Install the JDK (Java Development Kit) on a Mac

    Visit the JDK download page. Open your web browser and visit oracle.com/downloads/index.html.

  • Picture 2 of How to Install the JDK (Java Development Kit) on a Mac Download the JDK installer. Once you're on the Downloads page, you'll need to navigate to the installer files:
  • Click the "Java" option.
  • Click "Java SE."
  • Click the "Download" button next to "JDK 8 with NetBeans."
  • Select "Accept License Agreement" and then click the download link for "Mac OS X" in the top section. This is the most recent release of the Java SDK with the NetBeans development environment.
  • Picture 3 of How to Install the JDK (Java Development Kit) on a Mac

    Double-click the downloaded installer. The installer is in .dmg format. Double-clicking it will open the installation interface.

  • Picture 4 of How to Install the JDK (Java Development Kit) on a Mac

    Follow the prompts to install the JDK. You'll be asked to enter your administrator password before installation can proceed.

  • Picture 5 of How to Install the JDK (Java Development Kit) on a Mac

    Delete the DMG file after installation (optional). This will help you save on disk space, since you don't need it after the JDK has been installed.[1]

  • Part 2 of 2:

    Creating Your First Program

  • Picture 6 of How to Install the JDK (Java Development Kit) on a Mac

    Open NetBeans from the Applications folder. This is the development environment for Java, and will allow you to easily write and compile code.

  • Picture 7 of How to Install the JDK (Java Development Kit) on a Mac

    Click File and select "New Project." This will start a new project in NetBeans.

  • Picture 8 of How to Install the JDK (Java Development Kit) on a Mac

    Select the "Java" category and the "Java Application" project. This will set NetBeans to create Java files for this project.

  • Picture 9 of How to Install the JDK (Java Development Kit) on a Mac

    Give the project a name and click "Finish." For this example, call it "HelloWorld." This will open the code editor after the project is created.

  • Picture 10 of How to Install the JDK (Java Development Kit) on a Mac

    Find the "// TODO code application goes here" line. Your program code will go underneath this line.

  • Picture 11 of How to Install the JDK (Java Development Kit) on a Mac Enter your program code on a new line. Press Return after the "// TODO code application goes here" line to create a new line with the same indentation. Type the following code:
    System.out.println("Hello World!"); 
  • Picture 12 of How to Install the JDK (Java Development Kit) on a Mac

    Click the "Run Project" button. This looks like a green Play button, and can be found in the toolbar.

  • Picture 13 of How to Install the JDK (Java Development Kit) on a Mac

    Check the Output tab to see your project in action. This frame will appear at the bottom of your screen after running the project.

  • Picture 14 of How to Install the JDK (Java Development Kit) on a Mac

    Fix any errors. If the project doesn't have any errors, you'll see "Hello World!" and "BUILD SUCCESSFUL" in the Output tab. If there are errors, you'll see which lines they occur on so that you can go back and fix them.[2]

  • Picture 15 of How to Install the JDK (Java Development Kit) on a Mac

    Continue learning Java. Now that you have the JDK installed and working, you can continue learning to program in Java. See Write Your First Program in Java for more beginner guides.

  • Marvin Fry Marvin Fry

    Update 04 March 2020

    ncG1vNJzZmismaXArq3KnmWcp51ktbDDjK2mZqGeqMGiuMtmq6GdXZ%2BxrHnJmq2aZZSaw6a4zqmknqakYriqwIyopWaZXaKupA%3D%3D