How to install JDK (Java Development Kit) on Mac OS X

Table of contents:

How to install JDK (Java Development Kit) on Mac OS X
How to install JDK (Java Development Kit) on Mac OS X
Anonim

With the Java Development Kit (JDK) installed on your Mac, you can write and compile Java programs. Installing the JDK is very simple, and it will also install the NetBeans IDE in which you write code and compile it for testing.

Steps

Part 1 of 2: How to install the JDK

1383636 1
1383636 1

Step 1. Open the JDK download page

Launch a web browser and go to oracle.com/downloads/index.html.

1383636 2
1383636 2

Step 2. Download the JDK installation file

For this:

  • Click Java.
  • Click on Java SE.
  • Click Download next to JDK 8 with NetBeans.
  • Check the “Accept License Agreement” box, and then click the “Mac OS X” link at the top of the page. This is the most recent Java SDK release with the NetBeans IDE.
1383636 3
1383636 3

Step 3. Double click on the downloaded DMG file

The JDK Installer window will open.

1383636 4
1383636 4

Step 4. Follow the instructions on the screen to install the JDK

You will be prompted for an administrator password.

1383636 5
1383636 5

Step 5. Delete the DMG file when the installation is complete (if you like)

This will free up disk space because you will no longer need this file.

Part 2 of 2: How to Create Your First Program

Step 1. Launch NetBeans from the Applications folder

It is a Java development environment in which you can write and compile programs. 2.

1383636 6
1383636 6

3 Click File> New project.

A new project will be created in NetBeans. 4.

1383636 7
1383636 7

5 Select the Java category and the Java Application project.

NetBeans will be configured to generate Java files for this project. 6.

1383636 8
1383636 8

7 Give the project a name and click Finish.

For example, name the project "HelloMir". The code editor will open. 8.

1383636 9
1383636 9

9 Find the line “// TODO code application goes here”.

The program code will be located under this line. 10.

1383636 10
1383636 10
1383636 11
1383636 11

Step 11. Enter the program code on a new line

Press ⏎ Return at the end of the "// TODO code application goes here" line to go to a new line with the same indentation. Enter the following code:

System.out.println ("Hello world!");

Step 12. Click the Run Project button.

It looks like a green play button and is in the toolbar. 13.

1383636 12
1383636 12

14 Click the Output tab to see how the program works.

The result can be seen at the bottom of the screen after starting the project. 15.

1383636 13
1383636 13

16 Correct any errors.

If the project has no errors, you will see "Hello world!" In the "Output" tab. and the words “Build successful”. If there are errors in the project, you will see in which lines they occur. 17.

1383636 14
1383636 14
1383636 15
1383636 15

Step 18. Continue learning Java

Now that you have installed the JDK, continue learning Java programming. Read this article on how to write your first Java program.

Popular by topic