C:\Users\Administrator\workspace\chuanzhi\bin\com\c07016>java UdpSentException in thread "main" java.lang.NoClassDefFoundError: UdpSent (wrong name:
com/c07016/UdpSent)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: UdpSent.  Program will exit.
在myeclipse下运行正常,在cmd下编译通过,运行时就出现上述提示。

解决方案 »

  1.   

    public class Test10 { public static void main(String []args){
    String ss = "I am a student,I come from tianjin";
    String Keywords = ss.replaceAll("I[^(come)]come","")
    .replaceAll("tianjin", "");
    System.out.println(Keywords);
    }
    }
    结果:I am a student, from 
      

  2.   

    UdpSent
    这个java中带有package,
    所以 需要java xxx.UdpSent
      

  3.   

    如果在当前目录下,用:
    java -cp ..\.. com.c07016.UdpSent或者退两级目录:
    C:\Users\Administrator\workspace\chuanzhi\bin>java com.c07016.UdpSent