This article will provide the complete procedure to download and install the JDK, and NetBeans. Moreover, it will discuss how to set up the environment for java.
Requirements to Run a Java Program
JDK is a development kit that contains tools like a compiler and debugger. Therefore, JDK must be installed on the system to run the code. Before heading towards JDK installation we need to understand what are the requirements to run a Java program.
- a machine that holds a memory of a minimum of 64 MB RAM.
- An Operating system like Linux, macOS, or Windows.
- an editor to write, compile and execute the source code of the Java program.
Finally, we have to install Java JDK’s latest version.
How to download JDK
From here this article will provide comprehensive guidance to install Java JDK on Windows 10 operating system.
Open the browser and search for the “java jdk download”. Most probably the first link will be the official oracle’s link as shown in the following snippet:
Click on the “oracle.com” link. The latest version of the Java JDK will appear, select the operating system of your choice. We are working on Windows operating system so we select the option accordingly as shown in the following snippet:
How to Install JDK
Once the executable file is downloaded:
Click on that file a pop-up window will appear:
Allow the permission to start the installation process:
Click on the Next button. In this way, the installation process will proceed further:
And finally when the installation process will complete the following window will appear:
How to setup up Environment Variable
When you are done with the installation process, open the directory where you install it. If you didn’t change the directory then the by-default path will be “C:\Program Files\Java\jdk-17.0.1”. Within this folder open the bin folder:
All java related executable files will be there in the bin folder. To run all the java related commands from the command prompt we have to set the bin folder path as our environment variable path. To do this just copy the path up to the bin folder:
Next, open the settings and click on the “System” option and here search for the environment variables:
Select the “Edit the system environment variables”. The below-given window will appear, click on “environment variables”
Select the path variable and then click on the “Edit” option to set environment variables:
A new pop-up window will appear, click on the new button and paste your bin folder’s path (i.e “C:\Program Files\Java\jdk-17.0.1\bin”). And lastly, click on the OK button:
Now we need to set the “JAVA_HOME” variable as well because JAVA_HOME refers to the location where JDK is installed.
How to set up JAVA_HOME Environment Variable
Now we will set the “JAVA_HOME” environment variable, for this purpose we will click on the new option
A new window will appear where we will set the variable name as “JAVA_HOME” and variable value as the path up to the JDK folder “C:\Program Files\Java\jdk-17.0.1”:
How to verify the Environment Variable
For verifying, we will open the new “command prompt” and we will type the following command:
When we will press the enter button, it will show the java version that we installed:
We will pass one more command to check if the environment variable is set perfectly for the JAVA_HOME or not:
It will return the path that we gave in our java home environment variable:
All the things are working perfectly and our system is ready to work with java.
To run a java program we can use any editor like notepad, eclipse, NetBeans, etc.
NetBeans is an easy-to-use tool that supports several programming languages. It is available for every operating system like Windows, Mac, etc. Considering these features, we will install NetBeans on our system for Java programming.
First Step
Search for the NetBeans in the browser and download it from the “netbeans.apache.org”:
Second Step
Select the operating system:
Click on the following link that starts the downloading:
Third Step
Now it’s time to run the downloaded file for this purpose right click on the file and run it as an admin. Allow the permission to start the installation process.
After the installation process, the following window will appear:
Lastly, click on the finish button and NetBeans is ready to use.
Writing First Program in NetBeans
Now we will write a simple program to check whether NetBeans is installed properly on our system or not.
We write a program to print hello world:
The above code is executed successfully and printed the following output:
Conclusion:
To set up the environment for the java programming we have to set the environment variables by going into the Settings >system >about >advanced system settings and select the environment variable to edit the path for java JDK.