How do I resolve ClassNotFoundException?

前端 未结 22 1502
后悔当初
后悔当初 2020-11-21 06:06

I am trying to run a Java application, but getting this error:

java.lang.ClassNotFoundException:

After the colon comes the location of the cla

22条回答
  •  南方客
    南方客 (楼主)
    2020-11-21 06:35

    To add the location of a class to your classpath via command line simply add -cp or -classpath and the location of the class while running it. I.E.

    java -cp "c:/location/of/file" YourProgram
    

    Or if you're running an IDE such as eclipse you can right click on the project -> build path -> configure build path and add the external JAR containing your class to the build path then it should work fine.

提交回复
热议问题