How to use IntelliJ bundled maven in terminal? - macos

Using MacOS Catalina. Installed IntelliJ. Maven works fine but in terminal mvn comand is not found. How to use IntelliJs maven in terminal?

Locating mvn installed using IntelliJ
If you are specifically looking for mvn location, installed using IntelliJ on MacOS: /Applications/IntelliJ IDEA CE.app/Contents/plugins/maven/lib/mvn
Executing mvn from terminal
Now, if you want to execute mvn from terminal, you need to add to your path.
Assuming that you'are using zshrc, which is my case, you'll need to add the following command to ~/.zshrc
export PATH="$PATH:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin"
Now, reopen your terminal, and you can call mvn.
Obs.: Thanks to nbro's answer
Solving "Permission Denied"
If you try to execute mvn and get "Permission Denied", you need to give execution permission:
chmod +x "/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/mvn"

In my case, I added the following 2 commands to ~/.zshrc (which is what I am using)
export PATH="/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin:$PATH"
# Otherwise we get a "permission denied"
chmod +x "/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/mvn"
Now, I can call mvn from the terminal.

On linux (Ubuntu) when installed by toolbox, it might be something like this:
/home/<username>/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.7142.45/plugins/maven/lib/..

In Windows You may find Idea location by env variable
PS > Get-ChildItem env:"Intellij IDEA"
Name Value
---- -----
IntelliJ IDEA C:\Users\unknownuser\AppData\Local\JetBrains\IntelliJ IDEA 2020.3.4\bin;
then use M2_HOME env variable to store related maven path
C:\Users\unknownuser\AppData\Local\JetBrains\IntelliJ IDEA 2020.3.4\plugins\maven\lib\maven3
and use it in the path
%M2_HOME%\bin

Mine under windows is under a weird location:
C:\Users\changeMe\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\222.3345.118\plugins\maven\lib\maven3

Note that on Windows, from a Terminal console using CMD, you can execute mvn command using CTRL+Enter in IntelliJ :
As of the feature description under https://blog.jetbrains.com/idea/2020/07/run-ide-features-from-the-terminal/, this feature is also supported for MacOs with Cmd+Enter.
Run highlighted command using IDE (default shortcut: Ctrl + Enter or Cmd + Enter)
Debug highlighted command using IDE (default shortcut: Ctrl + Shift + Enter or Cmd + Shift + Enter)

Related

bash: mvn: command not found

I've been trying to solve this for quite a while now, but nothing seems to work.
I need to run "mvn clean deploy -P release" from the Terminal in IntelliJ (on Mac).
But it keeps giving me the same error.
bash: mvn: command not found
I was able to run this command about 2 hours ago, but after closing and reopening IntelliJ, I am no longer able to run this command from the Terminal in IntelliJ.
Does anyone know why this happens and how I can fix this?
I figured it out: you have to press CMD + ENTER in IntelliJ for the command to work.

"code ." command is not working

I get this error:
code . is not recognised as an external or internal command, operable program or batch file
moreover shell commands are not coming in my compiler VS code neither do setx path "%path%;C:\Program Files\Microsoft VS Code" is working in command prompt .
It looks as if you do not have the code program installed. You can open the Command Palette,
Mac: ShiftCmdP
Windows/Linux: ShiftCtrlP
And search "install command", which should return this as one of the options:
Shell Command: Install 'code' command in PATH
Run that, and it should install the code command, after which you should be able to use it.
For Mac OS,
You can paste this into your terminal, or in your .bashrc file (or whatever shell config file you are using) :
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
I found it. In the "search" type environment variables then click on the "edit system environment variables".
Inside Environment variables->Path put C:\Users\{your_username}\AppData\Local\Programs\Microsoft VS Code\bin.
Go to the project folder and open the cmd with it typing in the location bar and then type code .
That will do.
in windows problem is with insiders version of VSC.
You can use 'code-insiders .' command or make a copy of 'code-insiders.cmd' file as 'code.cmd' inside folder with code-insider (use 'path' command to see where your VSC is installed)
make sure you run the command in C folder
Then click window key + R and type rundll32.exe sysdm.cpl,EditEnvironmentVariables
then enter .
It will open Environment Variables edit Path variable .
Check whether you have C:\Users\{pc name}\AppData\Local\Programs\Microsoft VS Code\bin if not add it and run code -v in C folder cmd
This worked for me !
For Windows OS
For Windows, you'll need to re-install code. You can download the latest version and just install it overtop of your existing install.
During setup, make sure to check the box to Add to PATH
See Also: The VSCode docs on installing the CLI
After installation, you need to restart your computer to make the PATH changes effective. Post restart, the command worked for me.
about linux, if u can't see the >shell option with ctrl+shif+p, You could install via
sudo snap install --classic code
and try again
code .

Idea's cmd and git bash don't see mvn command

Idea's cmd and git bash don't see mvn command.
If I run this out of Idea it works:
But in Idea's CMD or Bash I see "mvn: command not found"
Why this happens? I set path to C:\Maven\apache-maven-3.5.0\bin.
On Linux it works well.
these are issue with maven path configuration into your system. try to reconfigure the maven, you can also refer this link to configure.
https://www.mkyong.com/maven/how-to-install-maven-in-windows/
Set path as below
export PATH=$PATH:/c/Program\ Files/Java/jdk1.8.0_221/bin:/c/Program\ Files/apache-maven-3.6.1/bin

OSX: env variable is not available

In my gradle project, I am using Dropwizard Crypto for encrypting passwords. I have added the passphrase to IntelliJ env variable and when running "gradlew run" task got the error that can't decrypt.
I have also added the env variable to ~/.bash_profile and run the IntelliJ from terminal and got same error. It works perfectly fine on Windows but on Mac not working (My os is Sierra 10.12)
I have tried running the gradlew run task from terminal and got same error. Any help appreciated.
It should probably be in
~/.bash_profile (with a dot)
or
~/.profile
Try to
export IntelliJ=passphrase
from a terminal session and run gradlew from the same session.

PATH not working on Mac OS X 10.10.3

I want to configure maven and wildfly on my local mac computer. in terminal I use zsh shell. so, I input maven and wildfly home in .zshrc file as
MAVEN_HOME="/Users/myuser/Development/maven"
JBOSS_HOME="/Users/myuser/Development/wildfly"
and then
export PATH="$PATH:$JBOSS_HOME/bin:$MAVEN_HOME/bin"
but when I type maven command in terminal, it shows me this response
zsh: command not found: maven
then I put all 3 commands in .bashrc and .bash_profile files. but nothing. even after reboot. what is wrong?
Maven command is mvn, not maven :)

Resources