AndreaNobili
AndreaNobili

Reputation: 42997

How to use Eclipse embedded Maven installation from the command line?

I am using STS (the Eclipse version for Spring) and it use the Maven plugin. It works fine but this Maven version is embedded into Eclipse.

Now I have to use it from the shell (the DOS prompt). If I try to perfrom thje mvn clean statment I obtain this error message:

C:\Users\Andrea\Documents\workspaces\Real-Time\ud381\lesson1\stage1>mvn
"mvn" non è riconosciuto come comando interno o esterno,
 un programma eseguibile o un file batch.

This is in Italian languange and it simply say that it can't find an internal or external mvn command.

So I think that I have to add it to the PATH environment Windows variable so I will can use it inside the command prompt.

The problem is that I can't find where is this embedded Maven installation.

Where can I find it?

Upvotes: 10

Views: 23452

Answers (4)

sifr_dot_in
sifr_dot_in

Reputation: 3603

for this we have to install maven as maven is not configured to work out of STS (and terminal usage is out of STS usage).
follow the following to setup maven to work from terminal.
maven download link is here
download latest maven from here
extract it where ever you want.

i extracted as below (see the bin,boot,conf,... folders are shown below as in the image): enter image description here

as this maven download is extracted from zip file (it is not setup), you will have to add this extracted path to "PATH" variable in windows environment. follow this to set environment path:
enter image description here enter image description here enter image description here enter image description here

now "mvn" command must work.
in my case
i was executing "mvn" terminal command from within STS, which didn't work. so I restarted STS (spring tool suit) and the command started working.

Upvotes: 1

juan san juan
juan san juan

Reputation: 21

It is possible to use Embedded Maven (at least in Windows)

Add de installation-path\bin in variable PATH

Define M2_HOME=installation-path

Define JAVA_HOME

Installation path could be something like

C:\Users\juans\.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3\bin

Note: juans is the user

Upvotes: 2

Rüdiger Herrmann
Rüdiger Herrmann

Reputation: 20985

To my knowledge, the Maven runtime that is embedded in m2 (the plug-in that provides Maven support in Eclipse) is not suited to be used outside the IDE.

You will have to install regular Maven (available from https://maven.apache.org/download.cgi) to be able to use it from the command line. From my experience, using both in parallel works well.

Alternatively, you can use Maven wrapper in your project - thus avoiding the need to install Maven for you and your team mates.

Upvotes: 10

Tushar Kshirsagar
Tushar Kshirsagar

Reputation: 303

On my local system, i installed maven in regular manner and also i changed settings in eclipse maven to refer the locally installed maven, in preferences setting you can do this, thus both the maven will utilise the same binaries and will run from local and from eclipse as well.

Upvotes: 0

Related Questions