Question:

➜ ~ mvn

zsh: command not found: mvn

Answer:

step 1:
vim ~/.zshrc
step 2:(Add at the end of the file)
source ~/.bash_profile;
step 3:(Execution shell)
> source ~/.bash_profile

You can use mvn :

➜  / mvn

[INFO] Scanning for projects...
.......
Answer from sunmeilinbbs on Stack Overflow
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360010047820-zsh-command-not-found-mvn
zsh: command not found: mvn – IDEs Support (IntelliJ Platform) | JetBrains
I installed maven on my mac and it returns the mvn -version as 3.6.3. I installed maven, maven helper, maven runner, maven test support plugin, maven dependency helper etc., But the problem is when I run mvn -version, it returns zsh: command not found: mvn and when I click on maven tab on the right side vertical bar to run maven life cycle commands, the tab simply vanishes from the IDE until I restart the IDE.
🌐
Apple Community
discussions.apple.com › thread › 254967682
zsh: killed - Apple Community
I don't think its a mac os bug ... since mac os 13 and now the current version is 14.4. 384 1 ... You could try temporarily rename th ~/.zprofile, quit and restart Terminal, open a new window and see if the problem persists. If it does, you can put the file back.
Discussions

macos - Mac command line: zsh: command not found: mvn - Stack Overflow
I installed maven in /Users/chenmin/software/apache-maven-3.6.3, and when I type cat ~/.bash_profile, it returns: export PATH=$PATH:/Users/chenmin/software/apache-maven-3.6.3/bin export PATH=${PATH... More on stackoverflow.com
🌐 stackoverflow.com
Terminal zsh:killed - Apple Community
zsh: killed mkdir -m 700 -p "$SHELL_SESSION_DIR" Hello! I am in dire need of some assistance with my Mac. I was able to install it onto it through brew and was able to use it. My Mac just updated to the Ventura 13.4.1 (22F82). This happened Wednesday July 12th. More on discussions.apple.com
🌐 discussions.apple.com
June 7, 2023
macos - Maven commands resuting in Killed: 9 on MAC OS - Stack Overflow
WIN201-S9L:psg 201$ mvn -version Killed: 9 WIN201-S9L:psg 201$ sudo mvn -version Password: Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T00:03:14+05:30) Maven home: /Lib... More on stackoverflow.com
🌐 stackoverflow.com
January 13, 2021
macos - How to fix "Killed: 9" error in mac os? - Ask Different
Since I upgraded my Mac OS, some programs get this error when running: Killed: 9 I even execute them via sudo but they won't work. Any idea? More on apple.stackexchange.com
🌐 apple.stackexchange.com
October 25, 2016
🌐
Code2care
code2care.org › home › howto › [error] zsh: command not found: mvn
[Error] zsh: command not found: mvn | Code2care
January 26, 2026 - If you get mvn command not found when you run a maven command on macOS or any bash terminal then you have not set the PATH for maven home. You need to locate where Apache Maven got installed on your device, on my macOS Big Sur it got installed ...
🌐
Apple Community
discussions.apple.com › thread › 254910900
Terminal zsh:killed - Apple Community
June 7, 2023 - I don't know what macOS sets for a default, but nothing would be better at this point. Delete it and research how to customize it for what you need. ... The shell is still telling you that you have not entirely setup the Zsh shell yet. However, the first thing I would remove would be that homebrew eval statement in your ~/.zshrc file.
🌐
Stack Overflow
stackoverflow.com › questions › 65704643 › maven-commands-resuting-in-killed-9-on-mac-os
macos - Maven commands resuting in Killed: 9 on MAC OS - Stack Overflow
January 13, 2021 - WIN201-S9L:psg 201$ mvn -version Killed: 9 WIN201-S9L:psg 201$ sudo mvn -version Password: Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T00:03:14+05:30) Maven home: /Library/apache-maven-3.5.4 · For some reason mvn command works with sudo and result in "Killed: 9" without sudo. I am new to mac PC Cataline not sure what could be the issue?
Find elsewhere
🌐
Mkyong
mkyong.com › home › java › maven $java_home is not defined correctly on mac os
Maven $JAVA_HOME is not defined correctly on Mac OS - Mkyong.com
January 19, 2021 - $ mvn -version Error: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec/java_home/bin/java · Further Reading How to set $JAVA_HOME environment variable on macOS · On macOS 10.15 Catalina and later, the default Terminal shell is zsh.
🌐
Ruslan
ruslan.rocks › home › blog › zsh: command not found: mvn
zsh: command not found: mvn
August 18, 2024 - This error means that the shell cannot find the mvn command, which is typically due to one of two reasons: Apache Maven is not installed on your system. The mvn command is not included in your PATH environment variable.
🌐
Super User
superuser.com › questions › 1830280 › default-shell-zsh-but-responding-bin-bash
linux - Default shell zsh but responding bin/bash - Super User
February 14, 2024 - I'm definitely in the wrong place as I was able to return mvn -v with a version and now it's saying mvn isn't found. ... That message indicates you are running bash (it's trying to talk you into switching to zsh).
🌐
Medium
medium.com › @fraycs › how-to-solve-zsh-killed-on-macos-ventura-5c1b01d1ed8a
How to solve zsh: killed on MacOS Ventura | by Sebastían Pulido | Medium
February 1, 2023 - #if you have something like this in your .zshrc export PATH="$HOME/bin:/usr/local/bin:$PATH" # just comment out that line by adding a # at the beginning # export PATH="$HOME/bin:/usr/local/bin:$PATH" # if you have this message # MacPorts Installer addition on 2022-07-12_at_22:37:02: adding an appropriate $ export PATH=/opt/local/bin:/opt/local/sbin:$PATH # Finished adapting your PATH environment variable for use with MacPorts.
🌐
Reddit
reddit.com › r/youtubedl › "zsh: killed" error immediately after every command on m1 macbook
r/youtubedl on Reddit: "ZSH: Killed" Error immediately after every command on M1 MacBook
February 11, 2021 -

Hi, I'm pretty new to homebrew and the whole command line thing on the Mac, so please be kind ;) Every time I try to use YouTube-DL this happens:

youtube-dl --verbose "https://www.youtube.com/watch?v=lKeUCkBO8QA" zsh: killed youtube-dl --verbose "https://www.youtube.com/watch?v=lKeUCkBO8QA"

I spend hours googling for help, but I couldn't find anything. Can someone please explain to me what's going on there and wtf is killing that process?

Btw I got Vidl installed also.

🌐
GitHub
github.com › quarkusio › quarkus › issues › 13856
Native application gets Killed: 9 on macOS Big Sur with binutils on the path · Issue #13856 · quarkusio/quarkus
December 12, 2020 - Running mvn clean verify -Dnative ends with Failed to start native image, process has exited on macOS Big Sur. EDIT: the main problem is in binutils, see #13856 (comment) I didn't have this problem on the previous macOS version 10.15 Catalina. I noticed this issue only on macOS Big Sur. ... sudo xattr -d -r com.apple.quarantine target/getting-started-1.0.0-SNAPSHOT-runner target/getting-started-1.0.0-SNAPSHOT-runner Killed: 9
Author   quarkusio
🌐
DigitalOcean
digitalocean.com › community › tutorials › install-maven-mac-os
How to Install Maven on macOS | DigitalOcean
September 25, 2025 - Maven home: /opt/homebrew/Cellar/maven/3.9.11/libexec Java version: 17.0.8, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk@17/17.0.8/libexec/openjdk.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "14.2.1", arch: "aarch64", family: "mac" If you see an output similar to this, Maven is already installed, and you can proceed to Step 5 — Testing Maven with a Sample Project to verify its functionality. If the command returns zsh: command not found: mvn or a similar message, Maven is not installed or not configured in your system’s PATH.
🌐
Medium
medium.com › @rajeshmuthusamy › maven-setup-with-mac-and-visual-studio-code-4622bd5d9fe4
Maven Setup with Mac and Visual Studio Code | by Rajesh Muthusamy | Medium
April 14, 2023 - It’s possible that Visual Studio Code is not using the same shell as your Mac terminal. For example if you are using zsh shell, then the mvn might not be recognised inside visual studio code.
🌐
Csdn
ask.csdn.net › questions › 8918142
zsh: command not found: mvn 问题解析_编程语言-CSDN问答
October 31, 2025 - 在使用 macOS 或基于 Unix 的系统时,常遇到“zsh: command not found: mvn”错误,表明 zsh 无法识别 `mvn` 命令。此问题通常因未安装 Apache Maven 或未正确配置环境变量所致。即使已安装 Maven,若其二进制路径未添加到 `PATH` ...
🌐
Manager Forum
forum.manager.io › t › mac-os-server-zsh-killed-managerserver › 51630
Mac os server - zsh killed ./ManagerServer - Manager Forum
February 10, 2024 - Hello all, I’ve installed the arm server version for mac and tried to opened in via terminal, but nothing worked, i also disabled the unverified developers in the setting and using the command: sudo spctl --master-disable after running ./ManagerServer it gives me this zsh: killed ./ManagerServer ...
Top answer
1 of 9
85

Try following these if these might help:

Since your installation works on the terminal you installed, all the exports you did, work on the current bash and its child process. but is not spawned to new terminals.

env variables are lost if the session is closed; using .bash_profile, you can make it available in all sessions, since when a bash session starts, it 'runs' its .bashrc and .bash_profile

Now follow these steps and see if it helps:

  1. type env | grep M2_HOME on the terminal that is working. This should give something like

    M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1

  2. typing env | grep JAVA_HOME should give like this:

    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home

Now you have the PATH for M2_HOME and JAVA_HOME.

If you just do ls /usr/local/apache-maven/apache-maven-3.1.1/bin, you will see mvn binary there. All you have to do now is to point to this location everytime using PATH. since bash searches in all the directory path mentioned in PATH, it will find mvn.

  1. now open .bash_profile, if you dont have one just create one

    vi ~/.bash_profile

Add the following:

#set JAVA_HOME
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
export JAVA_HOME


M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1
export M2_HOME

PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH
  1. save the file and type source ~/.bash_profile. This steps executes the commands in the .bash_profile file and you are good to go now.

  2. open a new terminal and type mvn that should work.

2 of 9
69

Solutions above are good but they require ~/.bash_profile. /usr/local/bin is already in the $PATH and it can be confirmed by doing echo $PATH. Download maven and run the following commands -

$ cd ~/Downloads
$ tar xvf apache-maven-3.5.3-bin.tar.gz
$ mv apache-maven-3.5.3 /usr/local/
$ cd /usr/local/bin
$ sudo ln -s ../apache-maven-3.5.3/bin/mvn mvn
$ mvn -version
$ which mvn

Note: The version of apache maven would be the one you will download.