JDK is the basic software for compiling and running java programs. In this article, we will learn how to install JDK on your local PC.
- Download the latest version of JDK from the URL https://www.oracle.com/java/technologies/javase-downloads.html.
- Start the installation by double-clicking on JDK executable file.
- Choose the location where you want to install Java. Generally, it is installed c:\program files\java\jdk.
- After the installation of Java, you can find java tools (javac, java, Javadoc, jar) in c:\program files\java\jdk\bin.
- To run any java program you generally use tools like java compiler(javac) and java interpreter(java).
- javac and java all are command-line tools and invoked from the command line from the path where your program is saved.
- To enable your system to find these command-line tools (javac, java, Javadoc) from anywhere you need to set these commands path to an environment variable. So the system will automatically look up these commands.
Set the environment variable
- Copy the path of JDK. For example, as we have told you current JDK path is c:\program files\java\jdk.
- Open the environment variable dialog using the one following steps...
1. Search environment variable on your windows as shown in the following figure...
2. The second way to open the environment variable. Go to the This pc =>select properties => advance system settings => environment variable as shown the following snapshots.
3. As shown in the above dialog, there are two-section user settings and system settings. If you want to update the setting for the current login user use the user settings and update the setting for all users then use the system settings.
4. Now set the java path into the environment variable into the path variable as highlighted into the above dialog box.
5. If the path variable already exists, use the edit option to update the path otherwise create a new variable which name is path and value of the path is java path(c:/program files/java/JDK) that you have copied earlier.
6. Press the ok button to complete and update settings.
Check java path is set or not properly
To check that java is already installed or java path is properly installed follow the steps below...
- Open command prompt by searching cmd in the start menu or open the run box (win + R) then type cmd and press enter.
- Type javac and press enter. if the list of javac tools appears means java is installed and the path is set properly.
- If javac returns javac is not recognized as internal or external command means the java path is not set properly.