返回列表 回复 发帖

请大家看看这个程序有无错误

//HelloWorld.java
public class HelloWorld
{
    public static void main()
    {
        System.out.println("Hello World");
    }
}
可以编译为.class,但是在运行时
Exception in thread "main" java.lang.NoClassDefFoundError:HelloWorld
然后后面又写了一大堆,最后写:
Could not find the main class:HelloWorld. Program will exit.
更可恶的是,每个.class运行时显示这样的错误(只是名称不同)
应该是1.6,因为安装默认目录jdk1.6.0_15
还是不行对所有.class
Exception in thread "main" java.lang.NoClassDefFoundError: ****
Caused by: java.lang.ClassNotFoundException: ****
        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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: ****.  Program will exit.
****指名称
我将.class默认打开方式设为F:\Program Files\Java\jre6\bin,这样就可以不通过cmd而直接打开,结果何用cmd打开一样,还是这样显示,这使我排除了环境变量设置错误导致无法找到位置从而无法运行的可能
纠正一下是F:\Program Files\Java\jre6\bin\java.exe
//HelloWorld.java
public class HelloWorld
{
    public static void main(String[] args)
    {
        System.out.println("Hello World");
    }
}
jdk中的java无法打开该文件
返回列表