1

I have a simple JDBC project that fetches data from a database. I have used mysql-connector-java-5.1.12.jar for jdbc connection.

Now I want to create an executable jar of my project from command line (not from eclipse).

I tried using :

jar cfe myJar.jar com/demo/MySqlJDBC com/demo/MySqlJDBC.class

The jar was created, but it doesn't contain mysql-connector jar and so when I run the jar as:

java -jar myJar.jar

I get error like:

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

So, my question is how can I pack the mysql-cnnector-jar while creating jar of my project without using maven and eclipse (just from command line)

Prashant Prabhakar Singh
  • 1,120
  • 4
  • 15
  • 33
  • Possible duplicate of [Execute jar file with multiple classpath libraries from command prompt](http://stackoverflow.com/questions/13018100/execute-jar-file-with-multiple-classpath-libraries-from-command-prompt) – Nishesh Pratap Singh May 09 '17 at 08:07
  • This question is not a duplicate of [this](http://stackoverflow.com/questions/13018100/execute-jar-file-with-multiple-classpath-libraries-from-command-prompt) and most importantly all answers are 5 years old and suggest to use maven. I am trying to use command line only. – Prashant Prabhakar Singh May 09 '17 at 08:42

0 Answers0