Currently I am experiencing a problem with maven on my Mac OSx 10.10.5 Yosemite.
I installed the apache files today, and tried to set maven up only for it to not recognize itself.
I currently have a ~.bash_profile file with the three lines:
export JAVA_HOME=$(/usr/libexec/java_home)
export M2_HOME=/Users/vincenttomie/apache-maven-3.6.1/
export PATH=$PATH:$JAVA_HOME/bin:/Users/vincenttomie/apache-maven-
3.6.1/bin
When I do $Java_Home I get
/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home
When I do $M2_HOME I get
/Users/vincenttomie/apache-maven-3.6.1/
When I do echo $PATH I get below
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/vincenttomie/apache-maven-3.6.1/bin:/Users/vincenttomie/apache-maven-3.6.1/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/bin:/Users/vincenttomie/apache-maven-3.6.1/bin
When I try to do mvn -- version in the terminal it gives me the
~bash: mvn: command not found.
I was wondering if anyone knew what the problem could be.
Thank you!
Related
I know there are a lot of questions/answers about this question, but all were failed in my case.
I installed jdk 1.8 and then installed maven3.6.3, java runs well but mvn command didn't work, see my command output and env:
java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
mvn -v
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
mac OS version: 10.15.5
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
echo $PATH
/usr/local/apache-maven-3.6.3/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.
config in ~/.bash_profile
export M2_HOME=/usr/local/apache-maven-3.6.3
PATH=$M2_HOME/bin:$JAVA_HOME/bin:$PATH:.
#Mac OSX 10.15.5 or later version need this configure
export JAVA_HOME=$(/usr/libexec/java_home)
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export PATH
I also source ~./bash_profile to make configure effective.
I would suggest revert all the changes you have made in ~/.bash_profile. Checkout my way to make the maven work:
Download latest maven zip package apache-maven-<version>-bin.zip from Apache maven download page.
Unzip it to any place, e.g: ~/Develop/apache-maven-3.6.0
Create a link with command sudo ln -sf ~/Develop/apache-maven-3.6.0/bin/mvn /usr/local/bin/mvn (change version number per your case, if the local bin folder missing, just create it mkdir -p /usr/local/bin).
Check the installation mvn --version
Hope it works for you.
After hundreds updating configure file, now mvn -version can works, share my update and hope it can help you.
fill or update vim ~/.mavenrc(in the beginning, this file isn't exist)
# my MacOS is 10.15+
export Java_HOME=$(/usr/libexec/Java_home)
and then source ~/.mavenrc to let system env effective.
Summary:for my mac system, seems maven couldn't get JAVA_HOME from .bash_profile or .profile, so if you confirm your JAVA_HOME is set correctly and MAVEN_HOME configured, then you can have a try in this way.
I'm never used a mac before and this is the first time I've tried to setup a coding environment. I've gone through multiple of the pages on here that give suggestions as to what is wrong, but still getting mvn command not found
I've set my ~/.bash_profile as below:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
export JAVA_HOME
M2_HOME=/Applications/apache-3.6.1
export M2_HOME
PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH
A java -version returns the following
java version "12.0.2" 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
So I believe that to be fine
A echo $M2_HOME returns the following
/Applications/apache-3.6.1
Which from what I've seen would suggest that is also correct.
However, mvn -v returns the following:
-bash: mvn: command not found
I've tried restarting the terminal and source ~/.bash_profile
Any help greatly appreciated
James
A ~/.bash_profile like this works for me:
export JAVA_HOME=`/usr/libexec/java_home -v 12`
export M2_HOME=/Applications/apache-maven-3.6.1
export PATH=$PATH:$M2_HOME/bin
Make sure you have a valid Maven installation under /Applications/apache-maven-3.6.1 which has a bin folder inside with the actual executable.
Hope it helps.
Edit-1
Check the difference between:
/Applications/apache-3.6.1 vs.
/Applications/apache-maven-3.6.1
I have set correct path of JAVA and maven in mac still i am getting error when i try to see maven version: -bash: mvn: command not found
I have set path in bash file as below:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
export MAVEN_HOME=/Users/aadityaverma/Downloads/apache-maven-3.6.0
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
Note:
java -version - it is working fine, but
mvn --version Getting error as mentioned above,
mvn -version Getting error as mentioned above
Modify .bash_profile as follow:
$ vim .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
$ source .bash_profile
Then restart CLI and run maven again
mvn -version
More information about Important Java directories on Mac OS
i'm trying to install maven on my mac first i downloaded apache-maven-3.3.9 and then i entered this code on my bash:
export M2_HOME=$(/usr/local/apache-maven/apache-maven-3.3.9)
and
export PATH=${PATH}:/Users/sabrine/ant/bin:$JAVA_HOME/bin:$ANT_HOME/bin:$M2_HOME/bin:
but it doesn't work i got(i tried with mvn -v)
-bash: mvn: command not found
where is the problem? what should i do?
Please follow below steps on terminal
Create bash profile (will be created under home folder and will be hidden file)
$ touch .bash_profile
Edit bash profile in editor and put next 2 commands in file, save file.
export M2_HOME=/Users/srajp/apache-maven-3.5.3
export PATH=$PATH:/Users/srajp/apache-maven-3.5.3/bin
Then check Maven version
$ mvn --version
If needed please see detailed steps on my blog on How to install Maven on MAC OS?
Don't add $( ) around the paths, just use:
export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
Followed by yours:
export PATH=${PATH}:/Users/sabrine/ant/bin:$JAVA_HOME/bin:$ANT_HOME/bin:$M2_HOME/bin:
The above assumes that your maven installation is in /usr/local/apache-maven/apache-maven-3.3.9, and ls -ld /usr/local/apache-maven/apache-maven-3.3.9 gives non-error output.
You can install maven on mac using this command.
brew install maven
Please help me, I try to set tup maven 3.3.3 on macbook pro yosemite but wrong. I did it bellow:
Download apache-maven-3.3.3
Extract it to /usr/local
Open terminal and do these follow step:
cd /usr/local
export PATH=$PATH:/usr/local/apache-maven/apache-maven-3.3.3/bin
export JAVA_HOME=/usr/java/jdk1.8.0_25
restart terminal
mvn -version
But it show error:
-bash: mvn: command not found.
I am a beginner developer. Please help me.Thanks all
To manage java version you can use jenv
Edit .bash_profile
export M2_HOME=~/Documents/Tools/apache-maven-3.3.1
export PATH=$M2_HOME/bin:$PATH