-
我就是那个Newby~~~
2008-12-12
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://kenotic.blogbus.com/logs/32426715.html
http://www.codegravity.com/blog/noclassdeffounderror
A friend of mine wanted to start to learn java, and I wanted to help him, so we created a simple Hello World example.
public class Hello {
public static void main(String argv[]) {
System.out.println("Hello world !");
}}
then, when you compile it:
> javac Hello.java
and want to execute it:
> java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
We set the CLASSPATH and JAVA_HOME enviroment variable correctly, and the problem was still the same..
When we copied the Hello.class into a lib directory of JAVA_HOME, it worked, but not from the current directory !
We tried different versions of java.. and do you know where this stupid problem is?
in the CLASSPATH there should be:
CLASSPATH=.;c:\programme\jboss\lib;c:\programme\
j2sdk1.4.2_08\lib;c:\programme\j2sdk1.4.2_08\jre\lib; ...
yes.. a dot .. it means, that it will search for classes bytecode in the current directory !
you can also tell java to search the current directory with the -classpath parameter
> java -classpath . Hello
Problems like this can really discourage java newbies, and that moment was very embarassing :)随机文章:
I cannot sleep 2009-09-26Magnum 2008-11-02Girls don't cry 2008-05-11已经很久没有听音乐了 2007-10-18契诃夫:带小狗的女人 &书摘 2007-08-21
收藏到:Del.icio.us

评论
还有,你用这种方法很麻烦的,直接用JBUILDER多好,或者JCREATOR什么,没必要敲这么多JAVAC, JAVA了