How to add JAVA_HOME on Ubuntu?

On Ubuntu, we can add JAVA_HOME environment variable in /etc/environment file. Note /etc/environment system-wide environment variable settings, which means all users use it. It is not a script file, but rather consists of assignment expressions, one per line. We need admin or sudo to modify this it. Further Reading Ubuntu – EnvironmentVariables 1. JAVA_HOME 1.1 …

Read more

Maven $JAVA_HOME is not defined correctly on Mac OS

This article shows how to fix the Maven error JAVA_HOME is not defined correctly. Terminal $ mvn -version Error: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec/java_home/bin/java Further Reading How to set $JAVA_HOME environment variable on macOS 1. $JAVA_HOME and macOS 10.15 Catalina, macOS 11 Big Sur On macOS 10.15 Catalina and later, the …

Read more

How to Set $JAVA_HOME environment variable on macOS

This article shows how to set the $JAVA_HOME environment variable on older Mac OS X and the latest macOS 11. Topics macOS release history What is /usr/libexec/java_home $JAVA_HOME and macOS 11 Big Sur $JAVA_HOME and Mac OS X 10.5 Leopard $JAVA_HOME and older Mac OS X Switch between different JDK versions Solution Steps to set …

Read more

How to set environment variable on Ubuntu

On Ubuntu, there are two system-wide environment variables, both files need admin or sudo to modify it. /etc/environment – It is not a script file, purely assignment expressions, one per line. /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" JAVA_HOME=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64 LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/postgresql/8.3/lib /etc/profile.d/*.sh – Files with .sh extension in the /etc/profile.d/ folder. /etc/profile.d/myenv.sh export JAVA_HOME=JAVA_HOME=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64 export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/postgresql/8.3/lib export PATH=$PATH:$JAVA_HOME/bin Further Reading: Ubuntu …

Read more