1.2. Installing JDK
To develop Java applications, you need to install the Java Development Kit (JDK). Follow the steps below to install and configure the JDK on your system.
Step 1: Download the JDK
- Go to the Oracle JDK Downloads page.
- Select the appropriate JDK version for your operating system and architecture (e.g., Windows x64, macOS, or Linux).
- Download the installer file.
Step 2: Install the JDK
- Locate the downloaded installer file and run it.
- Follow the on-screen instructions to complete the installation process.
- Take note of the installation directory (e.g.,
C:\Program Files\Java\jdk-XX
), as it will be needed later.
Step 3: Configure Environment Variables
To ensure your system recognizes the JDK, you need to set up environment variables:
- Open your system's environment variable settings:
- Windows: Search for "Environment Variables" in the Start menu.
- macOS/Linux: Edit the shell configuration file (e.g.,
.bashrc
,.zshrc
, or.bash_profile
).
- Add a new environment variable:
- Variable Name:
JAVA_HOME
- Variable Value: The path to your JDK installation directory (e.g.,
C:\Program Files\Java\jdk-XX
).
- Variable Name:
- Update the
PATH
variable:- Append the
bin
directory inside the JDK folder to thePATH
variable (e.g.,C:\Program Files\Java\jdk-XX\bin
).
- Append the
Step 4: Verify the Installation
- Open a terminal or command prompt.
- Run the following command:bash
java -version
- If the installation was successful, the terminal will display the installed JDK version.