Debian - Warning: JAVA_HOME environment variable is not set. - how to solve it?

7 points
Asked by:

When I run mvn install commnad to build my java project on Debian 9 I get this warning:

Warning: JAVA_HOME environment variable is not set.

This warning causes that my java build fails.

How can I fix it?

1 answer
7 points
Answered by:

You need to ensure you have installed correct version of java, I suggest jdk 8.

1. To check java version, execute command:

java -version

2. If we install open JDK, the default location should be:


3. Open /etc/profile

vim /etc/profile

4. Set JAVA_HOME path and add java bin directory to the PATH variable. In order to do that, we need to add below 2 lines to /etc/profile

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin

5. Logout from putty, login again 

6. Ensure we have java on our PATH by executing below commnad:

echo $PATH

7. Ensure we have $JAVA_HOME env variable:


8. Run mvn install in your java project and warning should be gone.

0 comments Add comment
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂