Compiling Project on Windows CMD with MySQL Jar Connector

I have a Java project, it consists of 3 Java classes, one .properties file (including MySQL username, password, etc.) and mysql-connector-java-5.1.41-bin.jar

My question is how I could include mysql-connector-java-5.1.41-bin.jar when compiling. To do this, I do the following right now: Go to my Java project folder in CMD -> javac StartApp.java -> java StartApp. It works well, except that it cannot find mysql-connector-java-5.1.41-bin.jar when using methods that require it.

I am using Windows 7.

What should I do? Everything else works when the Jar runs, except that the MySQL connection doesn't work (since it can't localize the connector JAR). I'm getting desperate so any help is greatly appreciated!

+3


source to share


1 answer


Just add the cp argument to let Java know the classpath let's say you store your whole jar (mysql-connector-java-5.1.41-bin.jar) in the lib folder, use the following command:



java -cp "yourMain.jar;lib/*" StartApp

      

0


source







All Articles