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

人盡茶涼 提交于 2019-12-02 14:16:59

问题


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 ....


回答1:


You need to edit Manifest.txt file to set the classpath for jar

Also See

  • In Linux, how to execute Java jar file with external jar files?



回答2:


To resolve the problem you can create "Runnable Jar file" instead of "Simple Jar file" in Eclipse.



来源:https://stackoverflow.com/questions/11080499/error-java-lang-classnotfoundexception-com-mysql-jdbc-driver-while-running-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!