Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should be easy but the obvious CLASSPATH thing isn't working.

I'm on a linux system. I've got a java program that wants to access a MySQL database. If the code is relevant to the problem I can post it.

The code compiles fine.

When I try to run it I get this:



I set my CLASSPATH like this:



And, I believe that Driver.class should be accessible to java:



What am I missing? Yes, it's an ancient jar file but that shouldn't cause the error, I don't think.

Thanks.
 
author & internet detective
Sheriff
Posts: 38564
654
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Java classpaths, you need to specify the jar (or a wildcard) and not just the directory. The directory can only be specified for loose class files. Try adding this to your classpath:
/app/tomcat/lib/mysql-connector-java-3.1.12-bin.jar
 
Stan Lederer
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:For Java classpaths, you need to specify the jar (or a wildcard) and not just the directory. The directory can only be specified for loose class files. Try adding this to your classpath:
/app/tomcat/lib/mysql-connector-java-3.1.12-bin.jar


Thanks, Jeanne, I appreciate it. That did it.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!