找不到main
//. SwitchStudy.java
public class SwitchStudy {
public static void main(String[] args)
{
switch(5)
{
case 1: prt("1");
case 2: prt("2");
case 5: prt("5");break;
default: break;
}
}
static void prt(String str)
{
System.out.println(str);
}
}
运行报错:
Exception in thread "main" java.lang.NoClassDefFoundError: SwitchStudy/class
Caused by: java.lang.ClassNotFoundException: SwitchStudy.class
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: SwitchStudy.class. Program will exit.
[解决办法]
是否放在了包内? 完整的类名是必须带包名的。
[解决办法]
编译了吗?
[解决办法]
javaRE 的配置: path 和 classPath配置是否正确