我写了一个类可以编译通过,但运行时提示:
Exception in thread "main" java.lang.NoClassDefFoundError:BayesStat(wrong names:james/BayesStat)
BayesStat是我的类,名字是没错的,编译也没问题。
请问这是什么原因,应该如何修改?谢谢大家!

解决方案 »

  1.   

    public class NoClassDefFoundError
    extends LinkageError
    Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found. 
      

  2.   

    1。运行要带包名 如:`java james.BayesStat
    2。用IDE`(eclipse等,)就不会有这种问题了。
      

  3.   

    1.确认你的class中有
      public static void main(String [] args)
      方法
    2.如果你有包,请确认classpath中有".",且在编译时用java -d . ,在运行时用java 包名.类名如果你是初次用java ,最好用IDE,如JCreator,eclipse或jbuilder
      

  4.   

    你的类有main()方法吗?有的话看看路径问题。
      

  5.   

    先看有没有main方法,再看类路径的设置.