I was trying to set up the mvn command, I downloaded maven on the official Apache website and wrote export M2_HOME="/Users/Bohan/apache-maven-3.9.0" PATH="${M2_HOME}/bin:${PATH}" export PATH in the bash_profile. Then I tried command mvn -version to see if it works, it doesn't and shows Command not found 'mvn'. I searched and it says i need to type source .bash_profile to update the commands, then it works. Then I found out I have to type source .bash_profile every time I use a maven command.
I was expecting that once I configure the bash_profile and update the commands, it will work afterwards. It doesn't in fact I need to update the commands every time I use it. I tried restarting my computer. Closing terminal and reopening it which both didn't work. Same thing resulted, I need to update the commands every time. All answers were appreciated.
Edit: I was using MacOS, and i am not using Ubuntu(I will look into Ubuntu and SDKMAN.)
Edit 2: Thanks to Dan_Maff for pointing out I should change my bash_profile to bash. It was fixed but I'm curious why does it work?
Edit 3: Now I'm using it in IntelliJ Idea and it seems like the same problem...