Trouble shoot maven installation on mac - maven

This is my bash_profile file
export PATH=$PATH:$HOME/Desktop/apache-maven-3.6.3/bin
The unzipped maven download is present in $HOME/Desktop/apache-maven-3.6.3/bin. But
mvn -v
does not work. Anything I am missing?

Related

macbook 10.15.5 install maven failed: NB: JAVA_HOME should point to a JDK not a JRE

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.

Maven version is not displaying

I am using Mac book air and installed apache-maven-3.6.3-bin.tar, and unzipped it.
The maven folder which got created I have moved to /Users/ak/Applications/apache-maven-3.6.3
Then created .bash_profile under /Users/ak/Applications and provided following details and saved the files
export M2_HOME=/Users/ak/Applications/apache-maven-3.6.3
export PATH=$PATH:$M2_HOME/bin
Now when i tried ak#ak-MacBook-Air ~ % mvn -version
I am getting following error:
zsh: command not found: mvn

Zombie mvn: Maven uninstall troubles

I am currently struggling with an uninstalled maven 3.3.9 on my Ubuntu 16.04, which I uninstalled using the command
sudo apt-get remove --auto-remove maven
I have installed maven 3.6.1 in my local directory,
and command which mvn points exactly to the executable,
but when I'm trying to execute the command mvn --version it shows File not found (at the old /usr/bin path of the uninstalled 3.3.9 version)
bash: /usr/bin/mvn: File not found
So, obviously, there is some symbolic link or something else, but trying to find the broken link with the command
find . -type l | xargs file | grep broken from /
does not come up with any mvn link.
That's rather annoying, can please someone give me an idea how to get rid of the zombie mvn?

install maven on mac

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

Can't find maven in OS X Yosemite 10.10.4

Nothing when I type:
$ whereis mvn
but I guess it is somewhere because from Eclipse I can select a pom.xml file and run it as maven build
As pointed out in the comments, Eclipse brings its own bundled Maven. If you want to use Maven on the shell, I suggest you install Homebrew and then install Maven like this:
brew install maven
After that you should be able to use mvn on the command line.
By the way, to find out where mvn is, use:
which mvn

Resources