开发者

Exception in thread "main" java.lang.NoClassDefFoundError: DiServer <wrong name: ds/DiServer>

This is one of those terribly embarrassing questions I'm afraid.

I have a program in Eclipse:

    package ds;
    public class DiServer {
 public static void main(String[] args) {
    int foo = 0;
    int bar = 0;
    /*bla*/
    }
    }

Simple right? This works completely fine when run in Eclipse.

I want to run this from command line. I have copied bin Folder, with the ds开发者_Go百科 folder inside it and DiServer.class in ds, and .classpath

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

The error I get is Exception in thread "main" java.lang.NoClassDefFoundError: DiServer <wrong name:ds/DiServer> ... Could not find the main class: DiServer. Program will exit.

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.

Thanks very much in advance,

M


You class full name is ds.DiServer, not DiServer. From C:\My Documents\DiTest:

java -cp . ds.DiServer

And voilà.


goto C:\My Documents\DiTest\ds\

javac  DiServer.java

goto C:\My Documents\DiTest\

java ds.DiServer 

Also See

  • packages
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜