您好我正在尝试从命令行编译并运行我的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)
关于我做错了什么想法?
答案 0 :(得分:3)
将其java phoneticSearchPackage.PhoneticSearch