I have installed maven on my machine with Java already present. but when i hit any maven command it tells Java path is not set correctly. I tried with a lot of export commands as well but din't worked out for me
Logs
[root@sandbox test]# mvn --version
Error: JAVA_HOME is not defined correctly.
We cannot execute /opt/java/jdk1.8.0_131/bin/java/bin/java
[root@sandbox test]# whereis java
java: /usr/bin/java /usr/lib/java /etc/java /usr/share/java /opt/java/jdk1.8.0_131/bin/java
[root@sandbox test]# ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Sep 12 2017 /usr/bin/java -> /etc/alternatives/java
[root@sandbox test]# ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 26 Sep 12 2017 /etc/alternatives/java -> /opt/jdk1.8.0_141/bin/java
Anybody want more inputs on this can paste the command and i will paste the output for it.