Installing maven2 without openjdk

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 08:42:20

问题


by default ubuntu comes with openjdk. I installed jdk from sun, and removed openjdk, but with openjdk I had to remove maven2. How can I reinstall it without installing openjdk?

~$ java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) Server VM (build 22.1-b02, mixed mode)

~$ sudo apt-get install maven2
(...)
The following extra packages will be installed:
(...)
openjdk-6-jdk openjdk-6-jre openjdk-6-jre-headless
  openjdk-6-jre-lib
(...)
The following NEW packages will be installed:
(...)
openjdk-6-jdk openjdk-6-jre openjdk-6-jre-headless
  openjdk-6-jre-lib

Any help appreciated, I have googled a lot and I haven't found any solution :/


回答1:


You can simply download tar.gz archive from Maven web-site and unpack it to some directory like this (will unpack it to /opt):

tar -xzvf apache-maven-3.0.4-bin.tar.gz -C /opt

After it you need to set $M2_HOME variable:

export M2_HOME=<path_to_maven>

And add it to PATH:

export PATH=$PATH:$M2_HOME/bin

To check you can launch:

mvn -version



回答2:


For me this command solved the same problem fast:

sudo apt-get --no-install-recommends install maven




回答3:


Generally for Google Compute Engine, AWS or Cloud below commands will be useful

sudo wget http://www.eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz

sudo tar -xzvf apache-maven-3.3.9-bin.tar.gz -C /var/lib/

sudo vi /etc/profile.d/maven.sh

Add below lines to the file

export M2_HOME=/var/lib/apache-maven-3.3.9

export PATH=$PATH:$M2_HOME/bin

Save the file and close editor . Then execute below command to exit the connection or console and relogin

exit

Once reconnected or login, execute below command to check maven version

mvn -version


来源:https://stackoverflow.com/questions/9518523/installing-maven2-without-openjdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!