gpt4 book ai didi

java - 查找 Maven 版本并在 ubuntu 中设置 MAVEN HOME

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:21:09 26 4
gpt4 key购买 nike

我想我弄乱了一些东西。昨天一切正常。今天有很多问题..

1.我运行了这个命令

echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64/

然后

mvn --version
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

昨天它运行良好(返回 maven 版本,我认为是 3.0.4)。现在这已经开始产生问题了。怎么办?

  1. 同样在运行之后

    $java --版本 无法识别的选项:--version 无法创建 Java 虚拟机。

这是我的 .bashrc 文件的内容,我的/etc/environment 文件中没有任何内容。

PATH=$PATH:$HOME/.rvm/
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH

这是在我的/etc/profile 中

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
PATH=$PATH:$HOME:$JAVA_HOME/bin
export JAVA_HOME
export PATH
  1. 另外让我知道,我如何在其中设置 MAVEN_HOME..

如有任何帮助,我们将不胜感激。谢谢:)

最佳答案

也许我的配置给了你一个提示:

/$ uname -a
Linux jenkins 3.2.0-55-generic #85-Ubuntu SMP Wed Oct 2 12:29:27 UTC 2013 \
x86_64 x86_64 x86_64 GNU/Linux

/$ echo $PATH
/var/lib/jenkins/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin

/$ ls -l /usr/bin/java* / usr/bin/mvn*
lrwxrwxrwx 1 root root 22 Feb 21 2013 java -> /etc/alternatives/java
lrwxrwxrwx 1 root root 23 Feb 21 2013 javac -> /etc/alternatives/javac
lrwxrwxrwx 1 root root 24 Feb 21 2013 javaws -> /etc/alternatives/javaws
lrwxrwxrwx 1 root root 21 Feb 21 2013 mvn -> /etc/alternatives/mvn
lrwxrwxrwx 1 root root 26 Feb 21 2013 mvnDebug -> /etc/alternatives/mvnDebug

/$ ls -l /etc/alternatives/java* /etc/alternatives/mvn*
lrwxrwxrwx 1 root root 17 May 31 2013 /etc/alternatives/java -> \
/opt/jdk/bin/java
lrwxrwxrwx 1 root root 18 May 31 2013 /etc/alternatives/javac -> \
/opt/jdk/bin/javac
lrwxrwxrwx 1 root root 58 Feb 21 2013 /etc/alternatives/javaws.1.gz -> \
/usr/lib/jvm/java-6-openjdk-amd64/jre/man/man1/javaws.1.gz
lrwxrwxrwx 1 root root 24 Feb 21 2013 /etc/alternatives/mvn -> \
/usr/share/maven/bin/mvn
lrwxrwxrwx 1 root root 29 Feb 21 2013 /etc/alternatives/mvn.1.gz -> \
/usr/share/maven/man/mvn.1.gz
lrwxrwxrwx 1 root root 29 Feb 21 2013 /etc/alternatives/mvnDebug -> \
/usr/share/maven/bin/mvnDebug
lrwxrwxrwx 1 root root 34 Feb 21 2013 /etc/alternatives/mvnDebug.1.gz -> \
/usr/share/maven/man/mvnDebug.1.gz

/usr/share/maven/conf/m2.conf:

main is org.apache.maven.cli.MavenCli from plexus.core

set maven.home default ${user.home}/m2

[plexus.core]
optionally ${maven.home}/lib/ext/*.jar
load ${maven.home}/lib/*.jar

/$ java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

/$ mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: /opt/jdk1.7.0_21/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-55-generic", arch: "amd64", family: "unix"

关于java - 查找 Maven 版本并在 ubuntu 中设置 MAVEN HOME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26449957/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com