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

后端 未结 5 1646
轻奢々
轻奢々 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:23

    The error message gives you a clue:

    (wrong name: org/kodeplay/kodejava/NewHelloWorld)
    

    It looks like your class is called org.kodeplay.kodejava.NewHelloWorld. The Java command line needs to know the fully qualified class name:

    java -cp . org.kodeplay.kodejava.NewHelloWorld
    

    should do the trick.

提交回复
热议问题