我正在运行 Windows 7 和 cygwin(最新)
当我使用 cygwin 基本控制台时,maven 运行良好
当我打开 mintty 并运行 mvn 时,出现此异常
$ mvn --version
java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.codehaus.plexus.classworlds.launcher.Launcher. Program will exit.
Exception in thread "main"
我没看到任何不同。这是我的环境
$ env
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\slepecw\AppData\Roaming
BURN_AUTOPLAY=C:\Program Files (x86)\Roxio\OEM\Roxio Burn\
COMMONPROGRAMFILES=C:\Program Files (x86)\Common Files
COMPUTERNAME=SLEPECW
COMSPEC=C:\Windows\system32\cmd.exe
CYGWIN=nodosfilewarning
COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files
COMMONPROGRAMW6432=C:\Program Files\Common Files
DEFLOGDIR=C:\ProgramData\McAfee\DesktopProtection
EMC_AUTOPLAY=C:\Program Files (x86)\Common Files\Roxio Shared\OEM\
FP_NO_HOST_CHECK=NO
HOME=/c/Users/slepecw
HOMEDRIVE=C:
HOMEPATH=\Users\slepecw
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_26
LANG=C.UTF-8
LOCALAPPDATA=C:\Users\slepecw\AppData\Local
LOGONSERVER=\\CAIHDC-DC01
M3=%M3_HOME/bin%
M3_HOME=C:\Users\slepecw\Code\nmsc-misc\maven\apache-maven-3.0.3
NUMBER_OF_PROCESSORS=4
OS=Windows_NT
PATH=/c/Program Files/Common Files/Microsoft Shared/Windows Live:/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/c/Program Files/Dell/DW WLAN Card:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/WIDCOMM/Bluetooth Software:/c/Program Files/WIDCOMM/Bluetooth Software/syswow64:/c/Program Files/Intel/DMIX:/c/Program Files (x86)/Intel/Services/IPT:/c/Program Files (x86)/Common Files/Roxio Shared/DLLShared:/c/Program Files (x86)/Common Files/Roxio Shared/OEM/DLLShared:/c/Program Files (x86)/Common Files/Roxio Shared/OEM/DLLShared:/c/Program Files (x86)/Common Files/Roxio Shared/OEM/12.0/DLLShared:/c/Program Files (x86)/Roxio/OEM/AudioCore:/c/Program Files (x86)/Windows Live/Shared:/c/Program Files/SlikSvn/bin:/c/Users/slepecw/Code/nmsc-misc/maven/apache-maven-3.0.3/bin:/c/Program Files (x86)/WinMerge:/c/Program Files/TortoiseSVN/bin:/c/Program Files (x86)/Bitvise Tunnelier:/usr/cmd:/usr/bin:/c/cygwin/bin:/c/Program Files/TortoiseGit/bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_ARCHITEW6432=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=2a07
PROGRAMFILES=C:\Program Files (x86)
PSMODULEPATH=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
PWD=/cygdrive/c/Users/slepecw
PROGRAMDATA=C:\ProgramData
PROGRAMFILES(X86)=C:\Program Files (x86)
PROGRAMW6432=C:\Program Files
RCAUTOPLAY=C:\Program Files (x86)\Roxio\OEM\Roxio Central 5\
SERVTAG=3V7FWM1
SESSIONNAME=Console
SHLVL=1
SYSTEMDRIVE=C:
SYSTEMROOT=C:\Windows
TEMP=/tmp
TERM=xterm
TIA=10030
TMP=/tmp
USERDNSDOMAIN=CAIHDC.COMPAID.COM
USERDOMAIN=CAIHDC
USERNAME=slepecw
USERPROFILE=C:\Users\slepecw
VSEDEFLOGDIR=C:\ProgramData\McAfee\DesktopProtection
WINDIR=C:\Windows
_=/cygdrive/c/Program Files (x86)/Git/bin/env
我通常会开始从 java_home 和 classpath 进行挖掘,但它在 cygwin 的基本 shell 下运行的事实让我很难受。
答案1
您应该检查 JAVA_HOME、CLASSPATH 以及 java 可能关心的其他环境部分。控制台和 mintty 中的环境不一定相同,因为例如控制台通常通过 Cygwin.bat 调用,而 mintty 则不是,因此如果您在 Cygwin.bat 中设置了某些内容,它将不会显示在 mintty 会话中。