How to Set Java Environment Variables (Windows, Mac & Linux) | JAVA_HOME Setup
📌Set Java Environment Variables
Introduction
When you install Java (JDK), you must configure environment variables so your system can run Java commands like java and javac globally. In this guide, we’ll learn how to set up JAVA_HOME and update the PATH variable on Windows, macOS, and Linux.
🔹 Step 1: Install JDK
-
Download the latest JDK from Oracle Java Downloads.
-
Install it on your system.
-
Windows Default Path:
C:\Program Files\Java\jdk-17 -
macOS Path:
/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home -
Linux Path:
/usr/lib/jvm/java-17-openjdk-amd64
-
🔹 Step 2: Set JAVA_HOME and PATH
🖥️ Windows
-
Right-click This PC → Properties → Advanced system settings.
-
Go to Advanced → Environment Variables.
-
Under System variables, click New:
-
Variable name:
JAVA_HOME -
Variable value:
C:\Program Files\Java\jdk-17
-
-
Edit the
Pathvariable → Add:⚡Note:
-
If you don’t want to use
JAVA_HOME, you can directly add: -
This step is not strictly required if you already followed step 3 and 4, but it’s another way to make Java accessible system-wide.
-
🍏 macOS
-
Open Terminal.
-
Edit the shell profile (depends on shell):
-
For zsh (default in macOS Catalina+):
-
For bash:
-
-
Add the following lines:
This step is not strictly required if you already followed step 3, but it’s another way to make Java accessible system-wide.
Save the file, then run:
🐧 Linux
-
Open Terminal.
-
Edit your profile file:
-
Add the following lines:
This step is not strictly required if you already followed step 3 and 4, but it’s another way to make Java accessible system-wide.
Save the file and refresh:
🔹 Step 3: Verify Installation
Open a terminal/command prompt and type:
If configured correctly, it will display the installed Java version.
👉Watch Set Java Environment Variables in Action
✅ Conclusion
By setting JAVA_HOME and updating PATH, you ensure your system can compile and run Java programs globally. This setup is essential for working with Java-based tools, frameworks, and applications.
💼 Professional Support Available
If you are facing issues in real projects related to enterprise backend development or workflow automation, I provide paid consulting, production debugging, project support, and focused trainings.
Technologies covered include Java, Spring Boot, PL/SQL, Azure, and workflow automation (jBPM, Camunda BPM, RHPAM).
📧 Contact: ishikhanirankari@gmail.com | info@realtechnologiesindia.com
🌐 Website: IT Trainings | Digital metal podium
Comments
Post a Comment