Installing JDK in java

Installing JDK

Installing the Java Development Kit (JDK)

Java programmers and software developers must manually install the Java Development Kit (JDK) on their laptops, desktops, or computers to develop and run Java applications. The JDK software provides Java developers with all the tools and controls they need to compile Java program source code, debug program code, and develop and execute Java software GUI and CUI-based applications. Here is a step-by-step process for Java developers and programmers to manually install the JDK on multiple operating systems: Windows, Mac OS, Android, and Linux.

Installing JDK in java

Install the JDK Software on a Windows Operating System.

Step 1 – Download the JDK Windows version.

First, open the official Oracle JDK download page in your web browser. For Oracle JDK downloads or the latest version, manually find the latest JDK version.

Select the appropriate JDK version for the operating system installed on your computer. For most Java developer users, JDK 17 (LTS) or the latest stable version is recommended.

Now, under the “Windows” tab, click the “x64 Installer” file link to download the .exe file, such as jdk-17_windows-x64_bin.exe, to your computer.

Step 2 – Install the JDK version on your computer.

Once the installer file is downloaded to your computer, double-click the executable file to run the manual Java JDK software installation wizard.

Now, follow the proper step-by-step JDK software installation instructions. Unless the user has a specific reason to modify the installation directory during the installation process, you can install it with the default settings.

In Java installation, you can install and set up the JDK and JRE (Java Runtime Environment) together.

After the JDK software installation is complete, the JDK application will be automatically installed on your computer system.

Step 3 – Set the Java Environment Variables.

To compile and run Java programs from a CUI-based terminal window or command line, Java users need to set environment variable values.

Open System Properties in Windows.

Right-click on the This PC (or Computer) icon and click the Properties menu.

Now manually click Advanced System Settings.

Then under the Advanced tab, click Environment Variables.

Set JAVA_HOME.

Click the New option under System Variables and manually set the variable name to JAVA_HOME and the variable value to the JDK installation directory. For example, C:\Program Files\Java\jdk-17.

Update the PATH variable on your computer.

In the System Variables section, find the Path variable and click the Edit menu.

Add the JDK’s bin directory as the path. For example, in the path: C:\Program Files\Java\jdk-17\bin.

Verify the Java JDK installation on your computer.

Open the Command Prompt (cmd) application on your computer and type the following command:

java -version

If you followed all the steps correctly and everything is setup correctly, this will display the Java version information you manually installed.

Setup the JDK Java version on the Apple macOS operating system.

Step 1 – Download the latest Java JDK version.

Open the Oracle JDK download page in the Safari web browser on Mac OS. Select the latest JDK version from the Oracle JDK Downloads version list.

Download the macOS installer .dmg file for your desired Mac OS JDK version, such as jdk-17_macOS-x64_bin.dmg.

Step 2 – Install the Java JDK on Mac OS.

Once the .dmg JDK file is downloaded to your Mac OS computer, double-click the installer file to mount it. Double-click the .pkg file to start the installation process.

Follow all the instructions provided in the installer to complete the JDK setup installation on Mac OS.

Step 3 – Set the JDK Environment Variable on Mac (Optional).

You can set the JAVA_HOME variable in your Mac OS so that Java applications can easily find the JDK version.

Open a terminal window in Mac OS.

Add this line to your terminal or shell profile file, depending on the version (~/.bash_profile for Bash or ~/.zshrc for Zsh).

export JAVA_HOME=$(/usr/libexec/java_home)

After editing the JDK file, run it.

source ~/.bash_profile # type the following code for the Bash version

source ~/.zshrc # type the following code for the Zsh version

Step 4 – Verify the JDK installation in Mac OS.

In your terminal window, type java -version

If you followed all the steps here correctly and everything is installed correctly, your computer will display the Java version that the user manually installed.

Install the JDK on your Linux operating system.

In Linux operating systems, the JDK Java installation process depends on the Linux distribution version you’re currently using. For example, Ubuntu, RedHat, Fedora, CentOS, etc., the setup files and steps may vary depending on the version. Below are the JDK setup steps for Ubuntu and Debian-based Linux distributions.

Step 1 – Update the package repository in Linux.

First, you need to update the system package repository in your Linux operating system. To do this, execute the following command:

sudo apt update

Step 2 – Install the JDK version using APT in Linux.

Linux users can install the default JDK version available in the Ubuntu repository.

sudo apt install default-jdk

This allows users to install a specific version of Java. For example, if you have OpenJDK 17, users can use the following command:

sudo apt install openjdk-17-jdk

Step 3 – Set JAVA_HOME in Ubuntu Linux (Optional).

Linux and Ubuntu users can manually set the JAVA_HOME environment variable for Java development.

Find the path to the installed JDK in Ubuntu Linux.

sudo update-alternatives –config java

This will display the path to the installed JDK version.

To set the JAVA_HOME variable in your Ubuntu Linux version, edit the ~/.bashrc or ~/.zshrc file, depending on the shell version you use.

nano ~/.bashrc # or ~/.zshrc for Zsh shell terminal users

Add this line to the terminal shell file (replace <path-to-jdk> with the correct JDK path).

export JAVA_HOME=<path-to-jdk>

export PATH=$JAVA_HOME/bin:$PATH

Apply the new modification.

source ~/.bashrc # or source ~/.zshrc for Zsh Linux users

Step 4 – Verify the JDK Ubuntu installation.

Check that the JDK Java versions are installed in the proper order on your Ubuntu computer.

java -version

This will display the Java version information you have installed.

Installing JDK Java Versions in Mac, Linux, Windows, Summary.

  • Microsoft Windows – Download the .exe installer file from the Oracle JDK website, run the JDK installer file, and manually set the Java environment variables JAVA_HOME and PATH.
  • Apple macOS – Download the JDK .dmg installer file from the Oracle website for Apple Mac OS, run the installer file, and set the JAVA_HOME environment variable if needed.
  • Linux (Ubuntu/Debian) – Use the apt package manager to install the Oracle JDK version on Linux/Ubuntu, and also set the JAVA_HOME environment variable if needed.

Leave a Reply