To install Java on a Windows system, follow these steps:
- Go to the Oracle JDK download page.
- Accept the license agreement.
- Download the appropriate JDK installer for your Windows system (e.g., Windows x64 Installer for 64-bit systems or Windows x86 Installer for 32-bit systems).
- Once the download is complete, double-click the downloaded installer file to run it.
- Follow the installation wizard instructions.
- Choose the installation directory and click "Next".
- Wait for the installation process to complete.
- After installation, you may need to set up the
JAVA_HOME
andPATH
environment variables:- Right-click on "This PC" or "My Computer" and select "Properties".
- Click on "Advanced system settings".
- In the System Properties window, click on the "Environment Variables" button.
- Under System Variables, click "New" and add
JAVA_HOME
with the path to the JDK installation directory (e.g.,C:\Program Files\Java\jdk-11.0.12
). - Find the
Path
variable in the list of System Variables, select it, and click "Edit". - Add
%JAVA_HOME%\bin
to the end of the existing Path (e.g.,C:\Program Files\Java\jdk-11.0.12\bin
). - Click "OK" to save the changes.
- Open Command Prompt (cmd.exe).
- Type
java -version
and press Enter. - If Java is installed correctly, you should see the version information.
To install Java on a macOS system, follow these steps:
- If you don't already have Homebrew installed, open Terminal.
- Paste the following command and press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Follow the on-screen instructions to complete the installation.
- Open Terminal.
- Run the following command to install the AdoptOpenJDK package using Homebrew:
This command installs the AdoptOpenJDK distribution, which is one of the popular choices for Java development on macOS.
brew install --cask adoptopenjdk
- After installation, open Terminal.
- Type
java -version
and press Enter. - If Java is installed correctly, you should see the version information.
By following these steps, you can install Java on both Windows and macOS systems.