日期:2014-05-20  浏览次数:20811 次

java运行是错误提示,求解
C:\Users\Administrator\workspace\chuanzhi\bin\com\c07016>java UdpSent

Exception 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下编译通过,运行时就出现上述提示。

------解决方案--------------------
如果在当前目录下,用:
java -cp ..\.. com.c07016.UdpSent

或者退两级目录:
C:\Users\Administrator\workspace\chuanzhi\bin>java com.c07016.UdpSent