This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes classpath question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

classpath question

Wilson Oak

Joined: Apr 21, 2005
Posts: 19
Right now I have a class "ShowDataBase" which create a connection to mySQL database. So I put mysql-connector-java-3.1.10-bin.jar and ShowDataBase.class together in one directory. When I run java ShowDataBase,it shows following:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at ShowDataBase.main(

however, if I run "java -cp mysql-connector-java-3.1.10-bin.jar ShowDataBase", it displays:

Exception in thread "main" java.lang.NoClassDefFoundError: ShowDataBase

I am sure the ShowDataBase run correctly until Ecipse and contains no error.
Please help me out for this problem. I don't want to run it under Eclipse very time because it takes a lot memories....
Thx a lot.

[Bear edit: removed shouting!]
[ June 19, 2006: Message edited by: Bear Bibeault ]

marc weber

Joined: Aug 31, 2004
Posts: 11343

Please do not cross-post. People are less inclined to offer help when they find that the question they've just answered has already been answered in a different forum.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: classpath question
It's not a secret anymore!