I'm using Ubuntu and new to maven i started to install maven 3 with
wget http://archive.apache.org/dist/maven/maven-3/
3.1.0/binaries/apache-maven-3.1.0-bin.tar.gz
i need to install this version to be convenient with JDK6 after that i extracted this in /opt
then edited in .bashrc
export MVN_HOME="/tmp/apache-maven-3.1.0"
export PATH="$PATH:$MVN_HOME/bin"
i tested mvn -version but got
The program 'mvn' can be found in the following packages:
* maven
* maven2
Try: sudo apt-get install <selected package>
Have you checked which directories are already in $PATH and contain a mvn ?
Change your export statement to
export PATH="$MVN_HOME/bin:$PATH"
in order to make sure that your mvn comes first. Besides that you might want to scan for variants of mvn that are already on your system:
find / -name mvn
Related
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?
I have maven3.1.1 and maven3.2.5 installed on my mac.
When I do mvn -version it shows maven3.1.1
How can I switch to the other maven version 3.2.5 ?
Your Current bash profile would be pointing to the maven version 3.1.1 as shown below
~/.bash_profile
export M2_HOME=/Users/yourusername/apache-maven-3.1.1 (Path where you have installed maven 3.1.1)
export PATH=$PATH:$M2_HOME/bin
Change the bash profile as shown below
~/.bash_profile
export M2_HOME=/Users/yourusername/apache-maven-3.2.5 (Maven 3.2.5 path)
export PATH=$PATH:$M2_HOME/bin
Restart the terminal and hit command mvn -version and now it will be pointing to the latest version.
Using SDKMan might be a simpler way to switch between multiple Maven versions.
1) Install SDKMan which is a one-off thing: http://sdkman.io/install.html
2) Do sdk install maven yourVersion
3) To switch: sdk install maven anotherVersion
4) To switch again: sdk use maven yourVersion
SDKMan should simplify such operations for several other software frameworks like Java, Groovy, Spring, Gradle, etc.
Another way to create a soft link. Suppose you have two version like -
maven-v1 and
maven-v2
Now if you want to use maven-v1 then create a soft link -
ln -s /installation/directory/of/maven-v1 maven
Then in your .bash_profile export M2_HOME pointing this directory -
export M2_HOME=/path/to/maven
export PATH=$PATH:$M2_HOME/bin
If you are doing this at first time then you need to restart your terminal.But after that you just need to change the soft link to you expected version. Suppose, now you want to use maven-v2; just change the existing soft link -
ln -sf /installation/directory/of/maven-v2 maven
Now you don't need to restart the terminal.
In your ~/.bash_profile
Download the tar of the maven version you want to use and extract the contents you want to use. Example Maven 3.1.1
export M2_HOME=/Users/<path to maven>/apache-maven-3.1.1
export PATH=$PATH:$M2_HOME/bin
If you have zsh, then change the ~/.zprfile
do not use M2_HOME. directly go for export PATH=$PATH:/usr/{maven...path}/bin
I've developed a function for ~/.zshrc and ~/.bashrc files to choose a different maven version according to the project without having to install more maven versions but taking advantage of docker.
So I use my maven installed in my machine with: mvn clean install
And I use my maven in docker with: maven jdk8 clean install or maven jdk11 package for example.
Here the function:
# executes a containerized version of maven so you won't have to install to your computer.
# you need to have docker installed and running.
# you can specify 'jdk8' or 'jdk11' as first argument to switch jdk.
# if not specified, jdk11 is the default.
# usage example:
# /your/maven/project/directory - $ maven jdk8 clean install
# /your/maven/project/directory - $ maven clean package
maven() {
if [[ "$1" == "jdk8" ]]; then
docker run --rm -v $PWD:/usr/src/app -v $HOME/.m2:/root/.m2 -w /usr/src/app maven:3.8-adoptopenjdk-8 mvn "${#:2}"
elif [[ "$1" == "jdk11" ]]; then
docker run --rm -v $PWD:/usr/src/app -v $HOME/.m2:/root/.m2 -w /usr/src/app maven:3.8-eclipse-temurin-11 mvn "${#:2}"
else
docker run --rm -v $PWD:/usr/src/app -v $HOME/.m2:/root/.m2 -w /usr/src/app maven:3.8-eclipse-temurin-11 mvn "$#"
fi
}
I'm new to storm and maven i installed
Apache Maven 3.1.0
and need to use it to maven a project
when i used mvn compile exec:java -Dexec.classPathScope=compile -Dexec.mainClass=MYClass.cr
I got
The program 'mvn' can be found in the following packages:
* maven
* maven2
Try: sudo apt-get install <selected package>
except
mvn -version
Apache Maven 3.1.0
Your problem is that you are running /usr/bin/mvn (verify this by typing which mvn). This is where apt-get will install maven. However, you have installed maven somewhere under /opt, so simply running mvn isn't finding the maven you installed.
First ensure that your .bashrc is updated to include the correct path, and that the new path is before /usr/bin
PATH=/opt/apache-maven-3.1.0/bin:$PATH
Then you need to ensure that .bashrc is loaded. You can log out and in again, start a new console, or simply source it (. ~/.bashrc).
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
I am not able to install maven in Ubuntu 12.04
I tried : sudo apt-get install maven
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package maven is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'maven' has no installation candidate
when i run : apt-cache search maven
libapache-pom-java - Maven metadata for all Apache Software projects
libcommons-parent-java - Maven metadata for Apache Commons project
maven-ant-helper - helper scripts for building Maven components with ant
maven-repo-helper - Helper tools for including Maven metadata in Debian packages
libjenkins-plugin-parent-java - Jenkins Plugin Parent Maven POM
I am getting a message like this. How to resolve this ?
First search for Maven package....
For that run this command in terminal..
apt-cache search maven
Then install...
sudo apt-get install maven
And at last for verification...
mvn -version
Hope this will help you.... ;)
Download maven from apache maven official site and extract.
Move the application directory to /usr/local
sudo cp -R apache-maven-X.X.X /usr/local
Make a soft link in /usr/bin for universal access of mvn
sudo ln -s /usr/local/apache-maven-X.X.X/bin/mvn /usr/bin/mvn
Verify mvn installation
mvn --version