In order to develop with Java, the Java Development Kit(JDK) needs to be installed on your local machine.
Installing and updating Java is similar to installing any other program on Windows. In addition, the JDK comes with the JVM and JRE which consist of a compiler and Java runtime environment.
Installing Java
Step 1 – First, navigate to the the official Java downloads website to download the latest JDK versions for your operating system.
Step 2 – Next, download the preferred JDK version as per your requirement.
In this example, the JDK 11 has been downloaded for windows OS. Upon the JDK download, double-click on the setup file(.exe) and click on the next button until the installation begins.
Step 3 – Next, open a command line window and type the following –
javac --version
This should ideally return the installed Java version. If it gives an error, probably the case that the Java path variable has not been set.
Setting the Java path variable
Step 4 – Locate the Advanced System Settings
in Windows.
Upon clicking on the Advanced system settings
, the System Properties
windows will pop up as shown in the following screenshot –
Step 5 – Click on the Environment Variables
button. We need to edit the path
variable in the System Variables
section by adding the JDK installation directory path as shown in the following screenshot –
Validating our Java installation
Step 6 – Finally, open a new command prompt and enter the java -version
and it should return the installed JDK version properly.
How to update Java
Different Java versions are released by Oracle frequently. Most of these releases contain important bug fixes and security patches to known vulnerabilities. Hence, it is important to keep the Java version on your system’sup to date. The Java update process is quite straightforward as described in the following.
Steps to Update Java on your computer
- Navigate to the
control panel
and find Java. Double-click on the Java entry. Java control panel
window pops up- Navigate to the Update tab and click on the
update now
button - This will start the update process that will update your Java installation to the latest minor version
How to Uninstall Java
If you ever need to uninstall Java from your computer, know that uninstalling Java is a straightforward process just like uninstalling any other program from your computer.
Steps to Uninstall Java
- Navigate to the
Control Panel
- Click on
Uninstall a Program
- This will redirect you to a list of already installed programs on your computer
- Select the Java version you want to uninstall and click the
Uninstall
button - This will permanently remove the selected Java version from your computer
Summary
In this article, we looked at how to install, update and uninstall Java to and from our computers. Though this article explains installing Java on Windows, similar approach can be used to install JDK on Linux distributions and MacOS.