How do I resolve ClassNotFoundException?

前端 未结 22 1498
后悔当初
后悔当初 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:30

    Add the full path of jar file to the CLASSPATH. In linux use: export CLASSPATH=".:/full/path/to/file.jar:$CLASSPATH". Other way worked (without editing the CLASSPATH) was unzipping the jar in the current project folder.

    Ways didn't work for me:

    1) Using -cp option with full path of jar file.

    2) Using -cpwith only the name of jar when located in the current folder

    3) Copying the jar to the current project folder

    4) Copying the jar to standard location of java jars (/usr/share/java)

    This solution is reported for class com.mysql.jdbc.Driver in mysql-connector-java.5-*.jar, working on linux with OpenJDK version 1.7

提交回复
热议问题