0
votes

Maven doesn't recognize the java_home path provide by $JAVA_HOME variable even though it clearly points to a valid installation.

i cant compile the project i want with this command when i'm located on the same directory as the pom.xml folder.

$ mvn package

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

if i want to check the version, same thing :

$ mvn -version
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

but the $JAVA_HOME is correctly set-up as i can see

$ echo $JAVA_HOME
/usr/lib/jvm/jdk-10.0.10

here are some info about my java installation

$ which java
/usr/bin/java
$readlink -f /usr/bin/java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java

2
You have set wrong java_home. Set java_home to /usr/java/latest. - Rathan Naik

2 Answers

1
votes

Ok here is what worked out after all:

1) Edit the JAVA_HOME variable in etc/environnement to whatever version of java you want to use. (I tried many version until one worked out)

2) source the new variable in the shell using this command:

oliver@oliver:~$ source /etc/environment

here is my environement file :

oliver@oliver:~$ cat /etc/environment

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" JAVA_HOME="/usr/lib/jvm/jdk-10.0.1" TEST="suppyall" export JAVA_HOME export TEST

0
votes

There is a difference between the symbolic link and JAVA_HOME

Link -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java JAVA_HOME (check path is available?) ->/usr/lib/jvm/jdk-10.0.10