0

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

3
  • What does this command do? java -cp mysql-connector-java-5.0.4-bin.jar -jar myJar.jar Commented Jun 18, 2012 at 9:56
  • @opyate: nothing useful: If you use -jar then all other classpath sources (CLASSPATH variable and -cp switch) will be ignored. Commented Jun 18, 2012 at 10:12
  • Thanks opyate for reply, I tried with this command but getting same error Commented Jun 18, 2012 at 10:13

2 Answers 2

0

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

Also See

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Jigar Joshi for reply, I tried with setting Class-path in Manifest.txt, but still I am getting the error
Please describe, what have you set and what is the error message
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.