java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

后端 未结 3 365
终归单人心
终归单人心 2021-01-11 09:29

I am getting this error when compiling my java program

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Then I knew that I should ad

3条回答
  •  [愿得一人]
    2021-01-11 09:59

    You have to put the full path to the jarfile in the classpath (including the filename):

    .;C:\j2sdk1.4.2_16\jre\lib;
    C:\Program Files\mysql-connector-java-3.1.144\mysql-connector-java-3.1.14-bin.jar
    

    As Hippo said, you have to restart cmd after changing that. If it doesn't work, launch your program like this:

    java -cp ".;C:\j2sdk1.4.2_16\jre\lib;
    C:\Program Files\mysql-connector-java-3.1.144\mysql-connector-java-3.1.14-bin.jar"
    my.class.Name
    

提交回复
热议问题