JAVA ENVIRONMENT SETUP

Since we've discussed and known what Java and its features are, it's time to start with Java and do some practical things. In this module we will learn how to download and set up Java on your machine.

Table of Contents

[hide]
  • Download Java SE Development Kit (JDK)
  • Install JDK on your system
  • Set Path in Java (Environment variables)

Download Java SE Development Kit(JDK)

JDK is the development environment for software developers which help them in building applications. JDK includes JRE and development tools such as Java compiler, Javadoc, Jar, and Debugger.

Steps to download latest Java SE development Kit :

Step 1- Navigate to Download Java link for downloading JDK.

Step 2- Click on JDK download present on the right side of the respective version.

Step 3- Choose .exe file according to the Operating System which you are using. Options provided are Linux, macOS and Windows. Example of latest version .exe file for windows 64bit OS. (jdk-14.0.1_windows-x64_bin.exe)

Step 4- After clicking the respective file, a pop-up will appear, where you have to accept the License Agreement by Oracle Java SE. Once you accept the agreement, you can click on the download button below. The file will be downloaded to your system.

NOTE : Java version greater than 9 needs 64 bit operating system.

Install JDK on your System

Hope you have downloaded the .exe file on your system.

java exe file

You can finally install this file on your system by clicking on it and following simple installation steps.

Since jdk is installed, we are one step closer to run our First Java Program. Next we need to set the environment variables- mainly JAVA_HOME and PATH variables. These environment variables point to the folder location where Java is installed.

NOTE: By default jdk will be installed in C:\Program Files\Java\jdk-14.0.1\ folder.

Set Path in Java (Environment variables)

These environment variables point to the folder location where Java is installed. But before learning how to set Java Path, let us know why do we set a Path in Java.

Why Do We Set Path in Java?

JAVA HOME and PATH are the most important environment variables with the help of which we have access to tools such as javac, java, etc which are present in jdk package. JDK package consists of JRE and development tools which are needed for program to execute.

NOTE : When you save the Java source file within the JDK / bin directory, you don't need to set the path, since all the resources are accessible in the current directory. But, if you have your Java file outside of the JDK / bin folder, JDK's path must be set.

How to set path in Java

Currently there are two ways to Set the Path in Java

  • 1. Temporary path
  • 2. Permanent path

Temporary path of JDK

JDK temporary path can be set easily. Following are the steps to set the path.

Step 1- Press Windows+R to open Run box. Type cmd and then click OK to open a regular Command Prompt.

Step 2- Copy the path of JDK/bin directory

Step 3- Type the following command in command prompt

javapath

Finally your Java Temporary Path is Set

Permanent path of JDK

JDK temporary path can be set easily. Following are the steps to set the path.

Step 1- Press Windows+R and type this command -rundll32.exe sysdm.cpl,EditEnvironmentVariables

permanent path

Environment variable tab will be open, you can also navigate to environment variable from System properties -> Advanced system settings -> Environment variables. This method is preferable.

Step 2- From Environment variable window click on New from user variable section.

uservaribale

Click OK, now your permanent path is set. You can run any Java program from any drive now.

Hope you now understand why the Java path is important and how it is set.