“We live to taste life twice, in the moment and in retrospection,” - Anaїs Nin.

  • 我就是那个Newby~~~

    2008-12-12

    Tag:

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    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-26
    Magnum 2008-11-02
    Girls don't cry 2008-05-11

    收藏到:Del.icio.us




    评论

  • 学数学,你是个很能忍耐的小盆友,赞一个~~~
  • sigh...搁浅了,T过期了,现在暂时也没再考的精力和时间,原来想出国是为了五湖结友,四海为家...现在想得更多的是学业和工作的事情...恩,别笑我,我也正儿开始八经想学业了,从良了,坦白的说,在国内也有很多能学的东西,以后有机会再继续出国的事情吧,只要G没过期-_-!!我都有心情继续,你呢?祝愿一切顺顺利利:)JAVA我也是新手,只是实习的公司喜欢这个,被折腾的要命
    Oksana回复转转说:
    嗯 我是想学习系统和生物来着,可能是脑经太死了,做别的事情都没有看数学来的激动,不管,先申着,不成了明年再找工作,到处都能学到东西,我想到处走走玩玩,然后干自己喜欢的事情,仅此而已。
    2008-12-16 08:54:37
  • 你不设置CLASSPATH,直接进入那个目录也是可以的
    还有,你用这种方法很麻烦的,直接用JBUILDER多好,或者JCREATOR什么,没必要敲这么多JAVAC, JAVA了
    Oksana回复转转说:
    好久不见,嗯~我是为了用swarm,在netbeans里面出了好些问题 不过搞定了 对了 你出国的事情忙的怎样?
    2008-12-13 22:44:58