简体   繁体   中英

Error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver while running JAR through Command line

I have a java program in that I am using mysql database connectivity code. I have added mysql-connector-java-3.0.10-stable-bin.jar and mysql-connector-java-5.0.4-bin.jar files in my resource folder in eclipse. When I run the program in Eclipse it runs fine. Then I have created a .jar file of my project included all jar files in that jar file. But when I run my jar file with java -jar myJar.jar command on DOS prompt it gives the error - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I tried with setting CLASSPATH of mysql-connector*.jar but still getting the same error. Please help me to resolve this problem?

Thanks in Advance ....

要解决该问题,您可以在Eclipse中创建“ Runnable Jar file ”而不是“ Simple Jar file ”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM