Languages

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

7 points
Asked by:
AnnLen
9180

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:
AnnLen
9180

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:

/usr/lib/jvm/java-8-openjdk-amd64

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:

echo $JAVA_HOME

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

0 comments Add comment
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join