2
我正在使用Apache Commons CLI 1.2来解析Java中的命令行参数。试图运行我的java类时遇到了NoClassDefFoundError
,但通过修复类路径来解决它。Java:使用Apache Commons CLI 1.2的NoClassDefFoundError
现在我有同样的异常,但在关于实际commons-cli
类为如下所示:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cl i/CommandLineParser Caused by:
java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineP arser
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source) Could not find the main class: com.amirsys.score.api.script.CMDContentPusher.
我能想到的唯一的事情就是设置类路径公地CLI罐子但那没用。我一直无法找到解决导入类的NoClassDefFoundError
的解决方案。我认为这些被编译到.class文件中?
这可能是有用的:http://stackoverflow.com/questions/1457863/what-is-the-difference-between-noclassdeffounderror -and-classnotfoundexception –
你究竟如何运行应用程序?看起来像commons-cli不在类路径中... – centic
我试图从Windows命令行运行它。那么我是否需要在最初的参数中添加公共cli的类路径?我有一种可怕的感觉,我会在类路径配置的纱球中迷路...有没有更简单的方法? –