File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes ClassNotFoundException: com.mysql.jdbc.Driver Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "ClassNotFoundException: com.mysql.jdbc.Driver" Watch "ClassNotFoundException: com.mysql.jdbc.Driver" New topic
Author

ClassNotFoundException: com.mysql.jdbc.Driver

Preet Dholabhai
Greenhorn

Joined: Jan 24, 2010
Posts: 19
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


Thanks & regards,
Preet
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

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.


My Blog: Down Home Country Coding with Scott Selikoff
Preet Dholabhai
Greenhorn

Joined: Jan 24, 2010
Posts: 19
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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

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

Joined: Jan 24, 2010
Posts: 19
thank you
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: ClassNotFoundException: com.mysql.jdbc.Driver
 
Similar Threads
Help with Arrays and x and y co ordinates
issue with logging!!
what to do about these exceptions
remove all user Sessions
java.net.HttpURLConnection