In order to develop and execute a java program/application, we need JDK to be available in our local machine. Today, in this lecture we are going to perform the following steps in order to make our system ready for Java development:
The JDK so installed is almost ready to use. But we will be able to effectively use it only after the environment is set up. But let us understand why is this step necessary.
Let us take an example. Whenever you feel hungry, you visit the kitchen. In order to visit the kitchen, the roadmap to the kitchen should be known. You are a member of this home, so you can easily find out the kitchen. But consider, a guest arrives and he/she is hungry. He/She is not aware of the kitchen location, so you need to direct him/her.
The purpose of Environment Setup serves the same intent. Here in the above example, you and the guest are java programs, and the kitchen is JDK containing necessary libraries.
Extending our previous example, we can have two approaches to direct our guests. Either, we explicitly tell them whenever they ask for it, or we have a kiosk at our common room with the location to the kitchen mentioned in it.
The first approach is temporary, while the second one is permanent.
So let us set up our path in both ways.
In order to set the temporary path, you need to proceed with the below-mentioned steps:
path = { The path selected in step 1 }
Select the JDK Path:
Before Setting the path, the compiler(javac
) command cannot be found
After Setting the path, the compiler(javac
), and an interpreter(java
) command is found successfully
It is not preferable to set java path temporarily, as it is not feasible and effective.
In order to set the permanent path, you need to proceed with the below-mentioned steps:
Step 1: Select the JDK path
Step 2: Open Control Panel
Step 3: Select System And Security
Step 4: Select System
Step 5: Select Advanced System Settings
Step 6: Select Environment Variables
Step 7: Select New Environment Variables and choose new from the user variables section
Step 8: In the name section, enter a valid name, and in the value section, enter the bin path copied in step 1.
Variable Name : Java_Path
Variable Value : C:\Program Files\Java\jdk-14.0.2\bin
After complete Environment Setup, we are ready to write our first Java Program.