Sunday, December 29, 2024
Google search engine
HomeLanguagesJavaDownload and Install Java Development Kit (JDK) on Windows, Mac, and Linux

Download and Install Java Development Kit (JDK) on Windows, Mac, and Linux

Setting up a Suitable Development Environment is necessary before one can begin creating Android Applications. It makes it easier for developers to use the tools required to create any Application and ensures that all Operations or Processes run smoothly. Download and Install JDK in order to create Android Application Source Files using the Java or Kotlin Programming Language. The system will execute the code using a set of Libraries and Compilers. JDK, JRE, and JVM should not be confused with one another, for more Differences between JDK, JRE, and JVM. This article describes the step-by-step process for installing and configuring the JDK on the 3 most popular Computer Operating Systems in order to begin the process of developing Android Applications.

Java JDK Download

The JDK can be installed on the following Platforms:

  1. Microsoft Windows
  2. Linux
  3. macOS

Install JDK on Microsoft Windows

Step 1: Download and Install Java Development Kit (JDK)

The very first step is to download the Oracle Java Development Kit (JDK) from the Official Oracle Website. For that, Head over to the Official Website.

Step 1 - Downloading JDK for Windows

 

You need to identify your system specifications to choose the Product/file description. The website will contain the latest version for your corresponding system. For Windows, we’ll be downloading the latest x64 Installer of Java SE Development Kit 18. After the download is complete, proceed to install the JDK by following the bootstrapped steps.

Step 1 - Installing JDK for Windows

 

Step 2: Configure Environment Variables

After the installation is complete, we have to configure environment variables to notify the system about the directory in which JDK files are located. Proceed to C:\Program Files\Java\jdk-{YOUR_JDK_VERSION}\bin (replace {-} with your JDK version)

Step 2 - Locating JDK File

 

To set the Environment Variables, you need to search Environment Variables in the Task Bar and click on “Edit the system environment variables”.

Step 2 - Configuring Environment Variables

 

Under the Advanced section, Click on “Environment Variables”.

Step 2 - Setting Environment Variable

 

Under System variables, select the “Path” variable and click on “Edit”. Click on “New” then paste the Path Address i.e. C:\Program Files\Java\jdk-{YOUR_JDK_VERSION}\bin. Click on “OK”.

Step 2 - Setting Path Environment Variable

 

Now, in the Environment Variables dialogue, under System variables, click on “New” and then under Variable name: JAVA_HOME and Variable value: paste address i.e. C:\Program Files\Java\jdk-{YOUR_JDK_VERSION}. Click on OK => OK => OK.

Step 2 - Setting JAVA_HOME Environment Variable

 

Step 3: Check the Java Version

Open Command Prompt and enter the following commands

java -version
javac -version

 

Install JDK on Linux

Step 1: Download and Install Oracle Java Development Kit (JDK)

The very first step is to download the Oracle Java Development Kit (JDK) from the Official Oracle Website. For that, Head over to the Official Website.

Step 1 - Download JDK for Linux

 

You need to identify your system specifications to choose the Product/file description. The website will contain the latest version for your corresponding system. For Linux, we’ll be downloading the latest x64 Debian Package of Java SE Development Kit 18. To install the downloaded JDK File using terminal, Open terminal and change your directory to downloads by using the command

$ cd downloads

To list files and packages present in the directory, Type

$ ls
Step 1 - Change Directory to Downloads for JDK

 

Now we use Debian Package Manager to configure our downloaded file for installation by typing

$ sudo dpkg -i jdk-{YOUR_JDK_VERSION}         (replace {-} with your version)

Enter your password as we have run an elevated prompt, i.e. the sudo or superuser do command, which is a quick way to grant specific users permission to perform specific system commands at the system’s root (most powerful) level.

Step 1 - Extract Package for Installing JDK

 

Now, Type the following commands to proceed with the installation

$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-{YOUR_JDK_VERSION}/bin/java 1
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-{YOUR_JDK_VERSION}/bin/javac 1

Step 2: Check the Java Version

Open the terminal and enter the following commands

$ java --version
$ javac --version
Step 2 - Checking Java Version

 

Step 3: Configure JAVA_HOME Environment Variable

After the installation is complete, we have to configure environment variables to notify the system about the directory in which jdk files are located. To find the Location of the JDK Files, run this command

$ sudo update-alternatives --config java

and copy the File Location.

In order to set the environment variable, you have to edit the environment file using this command

$ sudo gedit /etc/environment

Proceed to add JAVA_HOME=” /usr/lib/jvm/jdk-{YOUR_JDK_VERSION}

Proceed to save and close the file.

Step 3 - Configuring JAVA_HOME

 

Now we have to refresh the environment file by using this command

$ SOURCE /etc/environment

And echo the JAVA_HOME Path

$ echo $JAVA_HOME

Install JDK on MacOS

Step 1: Download and Install Oracle Java Development Kit (JDK)

The very first step is to download the Oracle Java Development Kit (JDK) from the Official Oracle Website. For that, Head over to the Official Website.

Step 1 - Download Oracle Java Development Kit

 

You need to identify your system specifications to choose the Product/file description. The website will contain the latest version for your corresponding system. For Mac, we’ll be downloading the latest x64 DMG Installer of Java SE Development Kit 18. After the download is complete, proceed to install the JDK by following the bootstrapped steps.

Step 1 - Installing Oracle Java Development Kit

 

Step 2: Configure environment variables

Now to configure, we have to open the terminal and pass the following commands. To find the Location of the JAVA_HOME, run this command

$ /usr/libexec/java_home -v{YOUR_VERSION}
Step 2 - Configuring Environment Variables

 

We have to set this output as our JAVA_HOME Environment Variable. You can use any command or code editor to edit the file, here we are using VS Code

$ code ~/. bash_profile
Step 2 - Configuring JAVA_HOME

 

At the very bottom, we have to export the path we obtained earlier i.e. 

$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-{YOUR_VERSION}.jdk/Contents/Home
Step 2 - Configured JAVA_HOME Path

 

Now we have to refresh the environment file by using this command

$ source ~/.bash_profile

And echo the JAVA_HOME variable

$ echo $JAVA_HOME
Step 2 - Refreshed JAVA_HOME Environment Variable

 

Step 3: Check the Java Version

In the terminal, enter the following commands

$ java -version
$ javac -version
Step 3 - Checking Java Version

 

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments