Pain with Maven and Java env variables

So I installed Java following this guide as I did many times, and set $JAVA_HOME in /etc/environment, java -version works fine.
After that I’m following this guide as I did many times and install maven. I don’t understand why I need to add to .profile JAVA_HOME once again but I always did and it worked, so I do it again and add at the end of the file lines:

export PATH
export PATH

I source both environment and .profile but for whatever reason it doesn’t work out and maven gives error that java home isn’t set while it’s set in 2 places even… I don’t get it, echo $JAVA_HOME works fine too. Ubuntu is 22.04

Asked By: Arzybek


The problem was that the path in JAVA_HOME should be without /bin/java part. Still don’t know why I have to duplicate it tho, without duplicating it in .profile it doesn’t work while it’s still being in /etc/environment.

Answered By: Arzybek