线程“main”中的异常java.lang.NoClassDefFoundError:名称错误:

时间:2014-01-17 15:33:04

标签: java

您好我正在尝试从命令行编译并运行我的java程序。

package phoneticSearchPackage;

public class PhoneticSearch {

我的文件夹结构是:

src\PhoneticSearchPackage\PhoneticSearch.java src文件夹旁边是.classpath.project

我使用以下方法编译它:

javac PhoneticSearchPackage/PhoneticSearch.java

PhoneticSearch.class

旁边创建PhoneticSearch.java

当我尝试使用以下方式运行它时:

java PhoneticSearchPackage.PhoneticSearch

我明白了:

Exception in thread "main" java.lang.NoClassDefFoundError: PhoneticSearchPackage /PhoneticSearch (wrong name: phoneticSearchPackage/PhoneticSearch) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14 2) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

关于我做错了什么想法?

1 个答案:

答案 0 :(得分:3)

将其java phoneticSearchPackage.PhoneticSearch