Java Maven 错误:无法找到或加载主类 org.codehaus.plexus.classworlds.launcher.Launcher
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33133809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven error : Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
提问by Prashanth
I'd been stuck with this simple issue for an hour now. Maven was working fine last week, I don't know what went wrong it gives me this error. I tried all the ways to debug and all the solutions found in StackOverflow and many other places. I even tried replacing M2_HOME path with M3_HOME and MAVEN_HOME. Nothing worked. I'm on OS X. Below is the output of few maven commands. I'll be happy to provide more information
我已经被这个简单的问题困住了一个小时。Maven 上周工作正常,我不知道出了什么问题,它给了我这个错误。我尝试了所有调试方法以及在 StackOverflow 和许多其他地方找到的所有解决方案。我什至尝试用 M3_HOME 和 MAVEN_HOME 替换 M2_HOME 路径。没有任何效果。我在 OS X 上。下面是几个 maven 命令的输出。我很乐意提供更多信息
$ mvn
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
$ which mvn
/Library/Maven-3.3.3/bin/mvn
$ echo $M2_HOME
/Library/Maven-3.3.3
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
$ which java
/usr/bin/java
$ /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Tomcat/bin:/Library/Maven-3.3.3/bin
$ java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
$ ls -lR /Library/Maven-3.3.3
total 56
-rw-r--r--@ 1 USERNAME wheel 19091 Apr 22 04:58 LICENSE
-rw-r--r--@ 1 USERNAME wheel 182 Apr 22 04:58 NOTICE
-rw-r--r--@ 1 USERNAME wheel 2541 Apr 22 04:55 README.txt
drwxr-xr-x@ 8 USERNAME wheel 272 Oct 14 12:24 bin
drwxr-xr-x@ 3 USERNAME wheel 102 Oct 14 12:24 boot
drwxr-xr-x@ 5 USERNAME wheel 170 Apr 22 04:55 conf
drwxr-xr-x@ 75 USERNAME wheel 2550 Oct 14 12:24 lib
/Library/Maven-3.3.3/bin:
total 64
-rw-r--r--@ 1 USERNAME wheel 230 Apr 22 04:58 m2.conf
-rwxr-xr-x@ 1 USERNAME wheel 7075 Apr 22 04:58 mvn
-rw-r--r--@ 1 USERNAME wheel 6007 Apr 22 04:58 mvn.cmd
-rwxr-xr-x@ 1 USERNAME wheel 1796 Apr 22 04:58 mvnDebug
-rw-r--r--@ 1 USERNAME wheel 1513 Apr 22 04:58 mvnDebug.cmd
-rwxr-xr-x@ 1 USERNAME wheel 1843 Apr 22 04:58 mvnyjp
/Library/Maven-3.3.3/boot:
total 104
-rw-r--r--@ 1 USERNAME wheel 52684 Aug 29 2014 plexus-classworlds-2.5.2.jar
/Library/Maven-3.3.3/conf:
total 32
drwxr-xr-x@ 3 USERNAME wheel 102 Apr 22 04:55 logging
-rw-r--r--@ 1 USERNAME wheel 10216 Apr 22 04:55 settings.xml
-rw-r--r--@ 1 USERNAME wheel 3649 Apr 22 04:55 toolchains.xml
/Library/Maven-3.3.3/conf/logging:
total 8
-rw-r--r--@ 1 USERNAME wheel 1126 Apr 22 04:55 simplelogger.properties
/Library/Maven-3.3.3/lib:
total 18656
-rw-r--r--@ 1 USERNAME wheel 136324 Jan 29 2015 aether-api-1.0.2.v20150114.jar
-rw-r--r--@ 1 USERNAME wheel 12637 Apr 22 04:58 aether-api.license
-rw-r--r--@ 1 USERNAME wheel 36745 Jan 29 2015 aether-connector-basic-1.0.2.v20150114.jar
-rw-r--r--@ 1 USERNAME wheel 12637 Apr 22 04:58 aether-connector-basic.license
-rw-r--r--@ 1 USERNAME wheel 172998 Jan 29 2015 aether-impl-1.0.2.v20150114.jar
-rw-r--r--@ 1 USERNAME wheel 12637 Apr 22 04:58 aether-impl.license
-rw-r--r--@ 1 USERNAME wheel 30705 Jan 29 2015 aether-spi-1.0.2.v20150114.jar
-rw-r--r--@ 1 USERNAME wheel 12637 Apr 22 04:58 aether-spi.license
-rw-r--r--@ 1 USERNAME wheel 25355 Jan 29 2015 aether-transport-wagon-1.0.2.v20150114.jar
-rw-r--r--@ 1 USERNAME wheel 12637 Apr 22 04:58 aether-transport-wagon.license
-rw-r--r--@ 1 USERNAME wheel 146876 Jan 29 2015 aether-util-1.0.2.v20150114.jar
-rw-r--r--@ 1 USERNAME wheel 12637 Apr 22 04:58 aether-util.license
-rw-r--r--@ 1 USERNAME wheel 4467 May 7 2013 aopalliance-1.0.jar
-rw-r--r--@ 1 USERNAME wheel 44908 May 7 2013 cdi-api-1.0.jar
-rw-r--r--@ 1 USERNAME wheel 21837 Apr 22 04:58 cdi-api.license
-rw-r--r--@ 1 USERNAME wheel 41123 May 7 2013 commons-cli-1.2.jar
-rw-r--r--@ 1 USERNAME wheel 173587 May 7 2013 commons-io-2.2.jar
-rw-r--r--@ 1 USERNAME wheel 284220 May 7 2013 commons-lang-2.6.jar
drwxr-xr-x@ 3 USERNAME wheel 102 Apr 22 04:55 ext
-rw-r--r--@ 1 USERNAME wheel 2256213 Nov 1 2014 guava-18.0.jar
-rw-r--r--@ 1 USERNAME wheel 2497 May 7 2013 javax.inject-1.jar
-rw-r--r--@ 1 USERNAME wheel 293671 Jul 24 2013 jsoup-1.7.2.jar
-rw-r--r--@ 1 USERNAME wheel 3449 Apr 22 04:58 jsoup.license
-rw-r--r--@ 1 USERNAME wheel 5848 May 7 2013 jsr250-api-1.0.jar
-rw-r--r--@ 1 USERNAME wheel 18116 Apr 22 04:58 jsr250-api.license
-rw-r--r--@ 1 USERNAME wheel 66349 Apr 22 04:57 maven-aether-provider-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-aether-provider.license
-rw-r--r--@ 1 USERNAME wheel 55090 Apr 22 04:56 maven-artifact-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-artifact.license
-rw-r--r--@ 1 USERNAME wheel 14964 Apr 22 04:56 maven-builder-support-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-builder-support.license
-rw-r--r--@ 1 USERNAME wheel 286726 Apr 22 04:58 maven-compat-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-compat.license
-rw-r--r--@ 1 USERNAME wheel 631881 Apr 22 04:57 maven-core-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-core.license
-rw-r--r--@ 1 USERNAME wheel 86051 Apr 22 04:58 maven-embedder-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-embedder.license
-rw-r--r--@ 1 USERNAME wheel 160817 Apr 22 04:56 maven-model-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 176410 Apr 22 04:56 maven-model-builder-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-model-builder.license
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-model.license
-rw-r--r--@ 1 USERNAME wheel 46099 Apr 22 04:56 maven-plugin-api-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-plugin-api.license
-rw-r--r--@ 1 USERNAME wheel 25957 Apr 22 04:57 maven-repository-metadata-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-repository-metadata.license
-rw-r--r--@ 1 USERNAME wheel 43032 Apr 22 04:57 maven-settings-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 43154 Apr 22 04:57 maven-settings-builder-3.3.3.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-settings-builder.license
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 maven-settings.license
-rw-r--r--@ 1 USERNAME wheel 375267 Feb 20 2015 org.eclipse.sisu.inject-0.3.0.jar
-rw-r--r--@ 1 USERNAME wheel 12637 Apr 22 04:58 org.eclipse.sisu.inject.license
-rw-r--r--@ 1 USERNAME wheel 205404 Feb 20 2015 org.eclipse.sisu.plexus-0.3.0.jar
-rw-r--r--@ 1 USERNAME wheel 12637 Apr 22 04:58 org.eclipse.sisu.plexus.license
-rw-r--r--@ 1 USERNAME wheel 13350 May 7 2013 plexus-cipher-1.7.jar
-rw-r--r--@ 1 USERNAME wheel 21837 Apr 22 04:58 plexus-cipher.license
-rw-r--r--@ 1 USERNAME wheel 4211 May 7 2013 plexus-component-annotations-1.5.5.jar
-rw-r--r--@ 1 USERNAME wheel 62458 Oct 29 2014 plexus-interpolation-1.21.jar
-rw-r--r--@ 1 USERNAME wheel 28555 May 7 2013 plexus-sec-dispatcher-1.3.jar
-rw-r--r--@ 1 USERNAME wheel 21837 Apr 22 04:58 plexus-sec-dispatcher.license
-rw-r--r--@ 1 USERNAME wheel 243128 Oct 29 2014 plexus-utils-3.0.20.jar
-rw-r--r--@ 1 USERNAME wheel 399672 Feb 20 2015 sisu-guice-3.2.5-no_aop.jar
-rw-r--r--@ 1 USERNAME wheel 26084 Jul 24 2013 slf4j-api-1.7.5.jar
-rw-r--r--@ 1 USERNAME wheel 14853 Apr 22 04:58 slf4j-api.license
-rw-r--r--@ 1 USERNAME wheel 10680 Aug 17 2013 slf4j-simple-1.7.5.jar
-rw-r--r--@ 1 USERNAME wheel 14853 Apr 22 04:58 slf4j-simple.license
-rw-r--r--@ 1 USERNAME wheel 11432 Apr 21 06:27 wagon-file-2.9.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 wagon-file.license
-rw-r--r--@ 1 USERNAME wheel 2259073 Apr 21 06:32 wagon-http-2.9-shaded.jar
-rw-r--r--@ 1 USERNAME wheel 11787 Apr 21 06:27 wagon-http-shared-2.9.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 wagon-http-shared.license
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 wagon-http.license
-rw-r--r--@ 1 USERNAME wheel 53543 Apr 21 06:27 wagon-provider-api-2.9.jar
-rw-r--r--@ 1 USERNAME wheel 11358 Apr 22 04:58 wagon-provider-api.license
/Library/Maven-3.3.3/lib/ext:
total 8
-rw-r--r--@ 1 USERNAME wheel 152 Apr 22 04:55 README.txt
采纳答案by Robert Scholte
Please remove M2_HOME as environment variable, it is already set by the mvn script. The only things you need to do is: add apache-maven-3.x.x/bin to your path, set JAVA_HOME as environment variable. So no need to add %JAVA_HOME%/bin to your path
Try to run mvn -v from /Library/Maven-3.3.3/bin/ folder first to confirm the installation is correct. Try to run mvn with xtrace info (tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html) and verify the commandline built up by Maven. I assume you get an unexpected classpath argument value.
请删除 M2_HOME 作为环境变量,它已经由 mvn 脚本设置。您唯一需要做的是:将 apache-maven-3.xx/bin 添加到您的路径中,将 JAVA_HOME 设置为环境变量。因此无需将 %JAVA_HOME%/bin 添加到您的路径中
首先尝试从 /Library/Maven-3.3.3/bin/ 文件夹运行 mvn -v 以确认安装正确。尝试使用 xtrace 信息 (tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html) 运行 mvn 并验证由 Maven 构建的命令行。我假设您得到了意外的类路径参数值。
回答by BeeOnRope
For what it's worth, I had the same error: the Could not find or load main class org.codehaus...
thing, but without any other info (you'll find many people with this error message - but usually accompanied by extra info such as class loading failures).
对于它的价值,我有同样的错误:Could not find or load main class org.codehaus...
事情,但没有任何其他信息(你会发现很多人有这个错误消息 - 但通常伴随着额外的信息,比如类加载失败)。
It turns out I had a corrupted install, perhaps a some files silently failed to unzip or something. A rm -rf
of the maven directory and re-download and unzipped fixed it.
事实证明我的安装已损坏,可能是某些文件无法静默解压缩或其他原因。rm -rf
maven 目录的A并重新下载并解压缩修复它。
回答by user6139322
I resolved the problem,it worked to me: delete the maven unzip file. and then get the newer one. then reconfig the path. because the original file was damaged. use mvn -v
我解决了这个问题,它对我有用:删除 Maven 解压缩文件。然后拿到新的。然后重新配置路径。因为原文件损坏了。 使用 mvn -v
回答by Crocode
EDIT : Note this is for Mac users
编辑:请注意,这是针对 Mac 用户的
M2_HOME
needs to be removed from the PATH
. By default, your PATH
might be picked up from one of the following files (for me, it was in ~/.profile
).
M2_HOME
需要从PATH
. 默认情况下,您PATH
可能会从以下文件之一中提取(对我来说,它在 中~/.profile
)。
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist
It might look something like this:
它可能看起来像这样:
export M2_HOME=/Applications/apache-maven-3.2.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
Remove the M2_HOME
variables, and any dependencies (in the example, the M2
variable uses M2_HOME
, so remove that, and the line after which uses $M2
) where ever it shows up.
删除M2_HOME
变量和任何依赖项(在示例中,M2
变量使用M2_HOME
,因此删除它,以及使用 之后的行$M2
)它出现的地方。
[source]
[来源]
Just to give more info on how this file is used, you can keep appending whatever location you want to include in the path.
只是为了提供有关如何使用此文件的更多信息,您可以继续附加要包含在路径中的任何位置。
For instance, if you want to include /User/batman/google-sdk
into path, then adding the below line to the end of the file will append /Users/batman/google-sdk
(in your case whatever the location of the folder is), to the PATH.
例如,如果您想包含/User/batman/google-sdk
到路径中,那么将以下行添加到文件末尾将附加/Users/batman/google-sdk
到 PATH(在您的情况下,无论文件夹的位置是什么)。
export PATH=$PATH:/Users/batman/google-sdk
.
export PATH=$PATH:/Users/batman/google-sdk
.
But make sure the PATH
already has some info before the above line.
但请确保PATH
在上述行之前已经有一些信息。
回答by wolfie
In my case M2_HOME
was pointing to /usr/share/maven3
; but ith should have been:
在我的情况下M2_HOME
是指/usr/share/maven3
; 但它应该是:
M2_HOME=/usr/share/maven
M2_HOME=/usr/share/maven
in .bashrc
在 .bashrc 中
回答by Bo Hu
In my experience, please check your /bin/mvn which is a POSIX shell script. In the script, it firstly finds maven related env from for e.g. /etc/mavenrc or $HOME/.mavenrc. In my case, in /etc/mavenrc, the M2_HOME env variable was set to the one I had removed, then after I set M2_HOME to the new maven installation, "mvn -v" worked.
根据我的经验,请检查您的 /bin/mvn,这是一个 POSIX shell 脚本。在脚本中,它首先从例如/etc/mavenrc 或$HOME/.mavenrc 中查找与maven 相关的env。就我而言,在 /etc/mavenrc 中,M2_HOME env 变量设置为我已删除的变量,然后在我将 M2_HOME 设置为新的 maven 安装后,“mvn -v”起作用了。
回答by kwic
What I did was I renamed (in my .bash_profile) the
我所做的是重命名(在我的 .bash_profile 中)
export M2_HOME=/usr/local/bin/mvn
export M2=$M2_HOME/bin
to
到
export M3_HOME=/usr/local/bin/mvn
export M2=$M3_HOME/bin
and then used the command (thanks TS!)
然后使用命令(感谢 TS!)
$ which mvn
and
和
$ echo $M2_HOME
And I saw there is a different path in the both so I changed the $M2_HOME
path to be the same as it showed me in the "Which mvn" command. In order to change this path I just edited the .bash_profile file where I had the variable.
我看到两者都有不同的路径,所以我将$M2_HOME
路径更改为与“Which mvn”命令中显示的路径相同。为了改变这个路径,我刚刚编辑了我有变量的 .bash_profile 文件。
回答by Z3d4s
For absolute new people to maven, make sure you download the "Binary archives" from the Maven site, and not the "Source archives".
对于 Maven 的绝对新手,请确保您从 Maven 站点下载“二进制档案”,而不是“源档案”。
回答by Vikky
Restarting the eclipse resolved the issue for me.
重新启动日食为我解决了这个问题。
回答by jmarks
Removing and re-installing worked for me.
删除和重新安装对我有用。
Particulars:
细节:
- It had been about a year since I had run maven on this Linux machine.
- Java had been upgraded from 7 to 8 (but other changes have also occurred).
- My M2_HOME/M3_HOME was not defined (so clearing this wasn't a solution).
- Running the
mvn
script in debug (bash -x mvn
) showed that the missing jar file was explicitly requested. - I could only find an older version of the
org.codehaus.plexus.classworlds
package/module.
- 我在这台 Linux 机器上运行 maven 已经大约一年了。
- Java 已经从 7 升级到 8(但也发生了其他变化)。
- 我的 M2_HOME/M3_HOME 未定义(因此清除这不是解决方案)。
mvn
在 debug (bash -x mvn
) 中运行脚本显示已明确请求丢失的 jar 文件。- 我只能找到旧版本的
org.codehaus.plexus.classworlds
包/模块。
Since it wasn't clear how to independently update the org.codehaus
jars, I let apt-get
pull in what it needed. Problem solved.
由于不清楚如何独立更新org.codehaus
罐子,我让apt-get
拉入它需要的东西。问题解决了。