我在包含此代码的List.java
文件夹中创建了一个文件UtilityPack
package Utilities;
public class List
{
private class node{}
public void insert(int data){}
public void print(){}
public static void main(String[] s){}
}
编译我做了
C:\UtilityPack>javac List.java
但是当我尝试运行时
C:\UtilityPack>java -classpath . List
或者
C:\UtilityPack>java List
我收到错误
Exception in thread "main" java.lang.NoClassDefFoundError: List (wrong name: Uti
lities/List)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
我一直在尝试从过去 3 个小时开始执行此程序,但没有任何效果..请帮助