我想我混淆了一些东西。昨天事情进展顺利。今天遇到很多问题..
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,我认为)。现在这已经开始产生问题了。该怎么办?
运行后
$ java --version 无法识别的选项: - 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
任何帮助将不胜感激。 谢谢:))
答案 0 :(得分:2)
也许我的配置会给你一个提示:
/$ 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"
答案 1 :(得分:1)
只有一个错误是java --version。应该是java -version(单破折号) 否则它现在工作正常......
答案 2 :(得分:0)
http://www.johnlabarge.com/post/33156663109/dreaded-maven-error-could-not-find-or-load-main-class此链接可以提供帮助,只需删除M2_HOME变量,然后添加M3_HOME变量。
顺便说一句,要打印Java版本号,你应该输入java -version
,而不是java --version
,只需要一个破折号,但是对于Maven,两者都是' mvn -version'并且mvn --version
没问题。