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

今天突然发现这个问题,自己解决不了,求大侠看看!
以前都是用myeclipse来写程序代码,程序都运行正常,今天突然用cmd来运行以前的程序?出现一下错误,求大侠帮忙看看》
Java code
 E:\WorkSpace\java\src\com\java\string>java StringBufferTest
                           Exception in thread "main" java.lang.NoClassDefFoundError: StringBufferTest (wro
                           ng name: com/java/string/StringBufferTest)
                                   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$100(Unknown Source)
                                   at java.net.URLClassLoader$1.run(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 sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)


------解决方案--------------------
麻烦你在E:\WorkSpace\java\src这个目录下,尝试执行:

java -cp . com.java.string.StringBufferTest

就是:
E:\WorkSpace\java\src>java -cp . com.java.string.StringBufferTest


看看结果