Java Installation
Last updated
Was this helpful?
Last updated
Was this helpful?
Java has various distributions; each serves specific purposes. Some popular ones include -
Oracle JDK: Official distribution from Oracle. Free for personal use, but commercial use may require licensing.
OpenJDK: Open-source and widely used for development and production.
Others: Amazon Corretto, Azul Zulu, Liberica JDK, AdoptOpenJDK (now Eclipse Temurin).
Visit the appropriate JDK provider’s website -
Oracle:
OpenJDK:
Other distributions as per preference.
Download the appropriate version (e.g., JDK 8, JDK 11, JDK 17, or later).
LTS (Long-Term Support) versions (e.g., JDK 8, JDK 11, JDK 17) are preferred for production.
Latest versions for experimental or cutting-edge features.
Run the downloaded installer (.exe
).
Follow the prompts in the installation wizard
Accept the license agreement.
Choose an installation directory or leave it as the default.
The installer will copy files and set up the Java Runtime Environment (JRE) alongside the JDK.
Set Environment Variables
Open System Properties → Environment Variables.
Add or update the following:
JAVA_HOME: Set to the JDK installation path (e.g., C:\Program Files\Java\jdk-17
).
PATH: Add %JAVA_HOME%\bin
to PATH to access java
and javac
commands from any terminal.
Verify installation
Open Command Prompt.
Run java -version
and javac -version
.
Install via the .dmg
package or use a package manager like Homebrew
If using the downloaded .dmg
Double-click the file and follow installation steps.
The installer sets up JDK in /Library/Java/JavaVirtualMachines/
.
Set Environment Variables
Edit ~/.zshrc
or ~/.bash_profile
:
Verify installation
Run java -version
and javac -version
in the terminal.
Download multiple versions (e.g., JDK 8, JDK 11, JDK 17) side-by-side and update the java path as needed.
Use tools like SDKMAN to manage multiple JDKs
Use LTS versions for stability in production.
Regularly update to the latest security patches.
Install only the necessary tools (e.g., avoid JDK if only JRE is required).
Automate installation in CI/CD pipelines using scripts or tools like Docker