Downloading and installing Java JDK and setting up the environment.
To download and install Java/JDK and configure the environment, you can follow these steps:
- Download JDK from the official Oracle website. You can visit https://www.oracle.com/java/technologies/javase-jdk14-downloads.html to download the latest version of JDK.
- Choose the appropriate JDK version for your operating system: Windows x64 Installer for Windows, macOS Installer for Mac, and Linux x64 for Linux.
- After the download is complete, run the downloaded installation program and follow the prompts to install it. During the installation process, you can choose the location of the JDK installation and other relevant options.
- After installation is complete, open the command prompt (Windows) or terminal (Mac/Linux).
- Use the following command to check if the JDK has been successfully installed.
- What is the current version of Java installed on this system?
- If the installation is successful, you will see the version information of the JDK.
- Configure the JAVA_HOME environment variable:
- For Windows users, right-click on “My Computer”, select “Properties”, then click on “Advanced System Settings”. In the window that opens, click on the “Environment Variables” button. In the “System Variables” section, click on the “New” button, enter the variable name as JAVA_HOME, and the variable value as the JDK installation path, for example “C:\Program Files\Java\jdk1.8.0_241”.
- For Mac/Linux users, open the terminal and enter the following command:
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_241Replace the path with your JDK installation path.
- Add the JDK bin directory to the system’s PATH environment variable.
- For Windows users, in the Environment Variables window, locate the “Path” variable in the “System Variables” section, click on the “Edit” button, and add “;%JAVA_HOME%\bin” to the end of the variable value.
- For Mac/Linux users, type the following command in the terminal:
export PATH=$PATH:$JAVA_HOME/bin - Verify if the configuration is successful by reopening the command prompt (Windows) or terminal (Mac/Linux) and entering the following command.
- What version of Java are you running?
- If successfully configured, you will see the version information of JDK again.
By doing so, you have successfully downloaded, installed, and configured Java/JDK. Now you can develop and run Java programs.