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?
You need to ensure you have installed correct version of java, I suggest jdk 8.
1. To check java version, execute command:
2. If we install open JDK, the default location should be:
3. Open /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:
7. Ensure we have $JAVA_HOME env variable:
mvn install in your java project and warning should be gone.