java.lang.NoClassDefFoundError when i run java file from terminal

后端 未结 5 1647
轻奢々
轻奢々 2020-12-20 06:44

I am a java newbie. I have been using Eclipse to test a simple java class (named NewHelloWorld) and it runs fine in the console. When I try to do the same thing from a termi

5条回答
  •  不知归路
    2020-12-20 07:30

    I had a similar problem running a HelloWorld program I had written with a text editor on Mac OS X. It ran fine on a remote Linux box, but running it from home directory I got the dreaded NoClassDefFoundError.

    Found that I could fix it either by running as:

    java -cp . HelloWorld
    

    or, without the classpath qualifier, after adding the current directory to my bash CLASSPATH for the current session:

    export CLASSPATH=.
    

提交回复
热议问题