线程“主”中的异常java.lang.NoClassDefFoundError:DiServer<错误名称:ds / DiServer> [英] Exception in thread "main" java.lang.NoClassDefFoundError: DiServer <wrong name: ds/DiServer>
问题描述
这是我害怕的一个非常尴尬的问题之一。
This is one of those terribly embarrassing questions I'm afraid.
我在Eclipse中有一个程序:
I have a program in Eclipse:
package ds;
public class DiServer {
public static void main(String[] args) {
int foo = 0;
int bar = 0;
/*bla*/
}
}
?这在Eclipse中运行时工作得很好。
Simple right? This works completely fine when run in Eclipse.
我想从命令行运行。我已经复制了bin文件夹,其中的ds文件夹和dsServer中的DiServer.class和.classpath
I want to run this from command line. I have copied bin Folder, with the ds folder inside it and DiServer.class in ds, and .classpath
我把它们放到一个单独的文件夹C:\我的文档\DiTest,打开命令提示符,转到C:\My Documents\DiTest\ds\并键入 java DiServer
I have put these into a separate folder, C:\My Documents\DiTest, opened command prompt, gone to C:\My Documents\DiTest\ds\ and typed java DiServer
我得到的错误是线程main中的异常java.lang.NoClassDefFoundError:DiServer<错误名称:ds / DiServer> ...找不到主要类:DiServer。程序将退出。
我尝试过java -classpath。 DiServer,java -classpath ../ .. DiServer,将.classpath移动到ds文件夹,但我似乎无法得到这个结果。我99%确定这是一个类路径问题,但我无法解决如何解决它。
I have tried java -classpath . DiServer, java -classpath ../.. DiServer, moving .classpath to the ds folder, but I can't seem to get round this. I'm 99% sure it's a classpath problem but I can't work out how to fix it.
我会非常感谢任何帮助,一如往常,和惯例提供一品脱总是站立。
I would greatly appreciate any help as always, and the customary offer of a pint always stands.
提前非常感谢,
M
推荐答案
您的全名是 ds.DiServer
,而不是 DiServer
。从 C:\My Documents\DiTest
:
You class full name is ds.DiServer
, not DiServer
. From C:\My Documents\DiTest
:
java -cp . ds.DiServer
And voilà。
这篇关于线程“主”中的异常java.lang.NoClassDefFoundError:DiServer<错误名称:ds / DiServer>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!