Basic
How to Install and Set Up Java 17 on Your System
To install and set up Java 17 on your system, follow the steps below. The process may vary slightly depending on your operating system. On Windows Download Java 17 Go to the official Oracle JDK download page or OpenJDK 17 Downloads if you prefer an open-source version. Select the appropriate installer for your Windows version […]
Artikel oleh Wayan · Sumber: Kode Java ↗
Terjemahan artikel ini belum tersedia. Isi asli ditampilkan.
To install and set up Java 17 on your system, follow the steps below. The process may vary slightly depending on your operating system.
On Windows
- Download Java 17
- Go to the official Oracle JDK download page or OpenJDK 17 Downloads if you prefer an open-source version.
- Select the appropriate installer for your Windows version (e.g.,
.msior.zip).
- Install Java 17
- Run the
.msiinstaller file and follow the setup instructions. - Install Java in the default directory or specify a custom directory (e.g.,
C:\Program Files\Java\jdk-17).
- Run the
- Set Environment Variables
- Open the Start menu, search for “Environment Variables,” and click on “Edit the system environment variables.”
- In the System Properties window, click on the “Environment Variables” button.
- Under “System Variables,” find the
Pathvariable and click Edit. - Add the path to the
bindirectory of your Java installation (e.g.,C:\Program Files\Java\jdk-17\bin). - Click OK on all windows to save your changes.
- Optionally, set a
JAVA_HOMEvariable:- Click New under “System Variables.”
- Name the variable
JAVA_HOMEand set its value to the path of your Java installation (e.g.,C:\Program Files\Java\jdk-17).
- Verify Installation
- Open a Command Prompt and run:
java -version- If installed properly, it will display the Java 17 version.
On macOS
- Download Java 17
- Visit the Oracle JDK or OpenJDK website, and download the
.dmginstaller for macOS.
- Visit the Oracle JDK or OpenJDK website, and download the
- Install Java 17
- Open the
.dmgfile and follow the installation instructions. - Java will be installed, usually in
/Library/Java/JavaVirtualMachines/.
- Open the
- Set Environment Variables (Optional)
- Open a terminal and edit the
~/.zshrc(for zsh users) or~/.bash_profile(for bash users) file using a text editor. - Add the following lines to set the
JAVA_HOMEvariable:
export JAVA_HOME=$(/usr/libexec/java_home -v 17) export PATH=$JAVA_HOME/bin:$PATH- Save and close the file, then reload the shell configuration:
source ~/.zshrc- Note: The
/usr/libexec/java_homecommand automatically detects installed Java versions.
- Open a terminal and edit the
- Verify Installation
- Run the following in Terminal:
java -version- It should show the Java 17 version.
On Linux
- Install OpenJDK 17
- Use your package manager to install OpenJDK 17:
- For Debian/Ubuntu-based systems:
sudo apt update sudo apt install openjdk-17-jdk- For Red Hat/CentOS/Fedora-based systems:
sudo dnf install java-17-openjdk-devel
- Use your package manager to install OpenJDK 17:
- Set Default Java Version
- If multiple Java versions are installed, you can set Java 17 as the default:
sudo update-alternatives --config java- Select the path for Java 17 from the list.
- Set Environment Variables
- Edit the
~/.bashrcor~/.zshrcfile and add:
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk export PATH=$JAVA_HOME/bin:$PATH- Save the file and reload it:
source ~/.bashrc - Edit the
- Verify Installation
- Run the following command:
java -version- It should display details about Java 17.
Optional: Verify Java Compiler
To ensure the javac compiler is working:
javac -version
That’s it! Now Java 17 is installed and ready to use.
