命令提示符下的java.lang.NoClassDefFoundError

hap*_*ppy 1 java

可能重复:
我可以从Eclipse创建的命令行程序运行吗?

当我尝试从命令提示符运行类文件时,我遇到异常,同样我在eclipse中运行,在那里我没有得到任何错误

试图从同一个文件夹运行

 Exception in thread "main" java.lang.NoClassDefFoundError: testClient (wrong nam
    e: com/mindcraft/queryExecutor/actionclass/testClient)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClassCond(Unknown Source)
            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)
    Could not find the main class: testClient.  Program will exit.
Run Code Online (Sandbox Code Playgroud)

Jon*_*eet 5

我怀疑你一个目录中运行com/mindcraft/queryExecutor/actionclass

相反,您应该在根目录(即父目录com)中运行,如下所示:

java com.mindcraft.queryExecutor.actionclass.testClient
Run Code Online (Sandbox Code Playgroud)