Setting up environment variables like JAVA_HOME
and NODEJS
is a key step in configuring your development environment properly. Here's how you can do it for Windows, Linux, and macOS:
JAVA_HOME
and NODEJS
:Find the installation paths:
Java: Usually something like C:\Program Files\Java\jdk-XX
Node.js: Something like C:\Program Files\nodejs
Set Environment Variables:
Press Win + S
, type Environment Variables, and open it.
Click Environment Variables…
Under System variables, click New:
Name: JAVA_HOME
Value: path to your JDK folder (e.g., C:\Program Files\Java\jdk-17
)
Add another variable for Node.js if needed:
Name: NODEJS
Value: C:\Program Files\nodejs
Update the Path
variable:
Select the Path
variable under System variables → Click Edit.
Click New and add:
%JAVA_HOME%\bin
%NODEJS%
Apply and Restart Terminal:
Open a new Command Prompt or PowerShell window.
Check with:
echo %JAVA_HOME%
java -version
node -v
For Bash: nano ~/.bashrc
or ~/.bash_profile
For Zsh: nano ~/.zshrc
# Java
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
# Node.js
export NODEJS=/usr/local/bin/node
export PATH=$NODEJS:$PATH
? Adjust the paths according to where Java and Node.js are installed.
source ~/.bashrc # or source ~/.zshrc
Verify:
echo $JAVA_HOME
java -version
node -v
Course :