• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassNotFoundException: com.mysql.jdbc.Driver

 
Preet Dholabhai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have set all the necessary environment variables required. My application runs from an IDE(JCreator) but when I try running it from command prompt then it doesn't work. i have kept my mysql-connector jar in ..jre1.6.0_06/jre/lib/ext . i have given the same path in my system variable JAVA_HOME. PL. help regarding this.

Regards,
Preet
 
Scott Selikoff
author
Saloon Keeper
Posts: 4021
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you need to specify the jar file explicitly in the command. This is why people tend not avoid running applications from command line, constructing the classpath can be tiresome.

Also, it's not good practice to put third party Jars in the JRE root.
 
Preet Dholabhai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks sir for the reply.
According to what i have understood from your reply, i shall make a new folder and keep all the third party jars in that folder. Then i shall give the path of that folder in system variables. Pl. correct me if I am wrong.

One more query i have is..I have made this application for a friend and do not wish to give him the source code. So, I copied all the .class files and I am thinking of creating a batch file for running my MainForm and provide him with that batch file.
The problem I faced in this was what I mentioned in my previous post i.e. Driver class not found. I have gone through many forums and followed all the steps mentioned their but in vain.

Pl. suggest something. Thank you.

Regards, Preet
 
Scott Selikoff
author
Saloon Keeper
Posts: 4021
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The folder can be wherever you run the app or in the server. Keep in mind that there are many different JDBC drivers and many versions.

The batch file needs to set the classpath to include the Jar. You can't just include the folder, you have to include the file by name. Of course, the path can be relative and include environment variables so you don't need to type the full path.

Since this is a classpath issue and really has nothing to do with JDBC, I'm transferring to the general Java forum.
 
Preet Dholabhai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic