3

I am trying to run maven on Ubuntu. Every time I run something like mvn -v I get: "The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE".

The thing is that I have set JAVA_HOME correctly. In /etc/environment: JAVA_HOME="/usr/lib/jvm/java-8-oracle".

Also, if I try echo $JAVA_HOMEit returns "/usr/lib/jvm/java-8-oracle", which is correct.

Am I doing something wrong?

  • 2
    As indicated by error, your current `JAVA_HOME` is pointing to `JRE` instead of `JDK`. Check: https://stackoverflow.com/questions/43496192/java-home-should-point-to-a-jdk-not-a-jre/43496275 – Sukhpal Singh Nov 03 '18 at 06:46
  • 1
    execute `env` command in terminal to check `JAVA_HOME` property set or not – Navin Gelot Nov 03 '18 at 06:56

1 Answers1

0

Most probably ubuntu source /etc/environment is set by default. If it does not work you need to add the below line inside ~/.bashrc

open it using nano/vim or any editor with sudo perimissions. Then add below line

source /etc/environment
PushpikaWan
  • 2,437
  • 3
  • 14
  • 23