请看http://web2.java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html我摘一段 Error Explanation Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp If you receive this error, java cannot find your bytecode file, HelloWorldApp.class. One of the places java tries to find your bytecode file is your current directory. So, if your bytecode file is in C:\java, you should change your current directory to that. To change your directory, type the following command at the prompt and press Enter: cd c:\java The prompt should change to C:\java>. If you enter dir at the prompt, you should see your .java and .class files. Now enter java HelloWorldApp again. If you still have problems, you might have to change your CLASSPATH variable. To see if this is necessary, try "clobbering" the classpath with the following command: set CLASSPATH= Now enter java HelloWorldApp again. If the program works now, you'll have to change your CLASSPATH variable. For more information, consult the section Check the CLASSPATH Variable in the installation instructions.
C:\jdk1.2\bin>javac hello.java
然后执行:
C:\jdk1.2\bin>java hello
javac helloworld.java,没有问题
java helloworld 得,扔出NoClassDefFoundError
给位能否解决呢?
多谢了
检查一下编译好的class文件名的大小写没有错!而且没有使用package之类的。
Error Explanation
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp If you receive this error, java cannot find your bytecode file, HelloWorldApp.class. One of the places java tries to find your bytecode file is your current directory. So, if your bytecode file is in C:\java, you should change your current directory to that. To change your directory, type the following command at the prompt and press Enter: cd c:\java
The prompt should change to C:\java>. If you enter dir at the prompt, you should see your .java and .class files. Now enter java HelloWorldApp again.
If you still have problems, you might have to change your CLASSPATH variable. To see if this is necessary, try "clobbering" the classpath with the following command: set CLASSPATH=
Now enter java HelloWorldApp again. If the program works now, you'll have to change your CLASSPATH variable. For more information, consult the section Check the CLASSPATH Variable in the installation instructions.
不过,有一点感受,如果要学好java,守住一个地方,java.sun.com,绝对没有错,什么都有
感谢tiger,robber
另外,建议sunyw兄,有问题,最好自己解决,可以通过论坛,新闻组的方式获取提示,自己琢磨出来的东西,很爽的,:)
多嘴多嘴,good luck