GeeCON Prague 2014*
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


JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

classpath question

Wilson Oak
Greenhorn

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 java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown 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(ShowDataBase.java:30)


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 ]

~WOak
marc weber
Sheriff

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
sscce.org
 
GeeCON Prague 2014
 
subject: classpath question