Exception in thread “main” java.lang.NoClassDefFoundError: wrong name

后端 未结 3 1945
情话喂你
情话喂你 2020-12-15 05:21

My file directory:

project/src/m2mcom/entities/AutomatedTelnetClient.java
           /web/Simple.java           
           /org/apache/commons/net/telnet/Te         


        
相关标签:
3条回答
  • 2020-12-15 06:09

    You're executing the command in the wrong folder, with the wrong classname. You need to use the fully qualified name (FQN) when running a Java class. And of course, you have to be in the right directory. In your example, the FQN of your class is m2mcom.web.Simple (combination of the package m2mcom.web and the simple name Simple).

    As far as deducing the right directory, your classes are stored in a hierarchical folder structure, which basically starts in C:\Users\Victor\Desktop\project2\src.

    So to correctly execute your program, from C:\Users\Victor\Desktop\project2\src, do;

    java m2mcom.web.Simple
    
    0 讨论(0)
  • 2020-12-15 06:09

    So you have to be in the directory right above the package name when you execute the java command which should be in the form packagename.classname without the .class suffix.

    0 讨论(0)
  • 2020-12-15 06:11
    package m2mcom.web;
    

    remove above line and recompile it. when you run your code in netbeans it including in a m2mcom.web package.that is not in your class file.

    0 讨论(0)
提交回复
热议问题