简体   繁体   中英

How to set Netbeans 11 to include jdbc driver in the distribution jar file?

When I run the maven project from Netbeans 11 everything works fine, but when I run it from command line with: java -jar program.jar I cannot connect to the mysql. I have also tried to run like I understood from similar posts on the same topic with: java -classpath mysql-connector-java-8.0.17.jar -jar program.jar Same problem. Is there a way to set up NetBeans 11 to generate the distribution jar able to use the jdbc driver?

I managed to solve this by adding mysql-connector-java-8.0.17.jar to Project Libraries like it was suggested in this post: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Eclipse , but also I needed to copy mysql-connector-java-8.0.17.jar in the same folder with the distribution jar.

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