GeeCON Prague 2014*
The moose likes Java in General and the fly likes class not found exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "class not found exception" Watch "class not found exception" New topic
Author

class not found exception

vainu siva
Greenhorn

Joined: Dec 08, 2007
Posts: 6
hi...while i am trying to run my java code...im gettin this error...is my jar file not found....
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found in [file:/usr/share/java/libgcj-3.4.3.jar, file:./, core:/]
at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.5.0.0)
at _Jv_FindClass(_Jv_Utf8Const, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at Conn.main(java.lang.String[]) (Unknown Source)
thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42042
    
  64
Welcome to JavaRanch.

How did you add the jar file to your classpath?


Ping & DNS - my free Android networking tools app
vainu siva
Greenhorn

Joined: Dec 08, 2007
Posts: 6
Actually i am having java in /usr/share.but inside it i didnt found jre,jdk.inside the java folder i found the following jar files.
db.jar,
ecj.jar,
libgcj-3.4.3.jar,
ecj-2.1.3.jar,
pg74.215.jdbc1.jar,
pg74.215.jdbc2ee.jar,
pg74.215.jdbc2.jar,
pg74.215.jdbc3.jar.I have put the mysql-connector-java-3.0.10-stable-bin.jar along these jar files.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42042
    
  64
Those files are most likely not added to your classpath automatically (they might be, depending on which directory they're in - I can't tell from your post). You need to do that explicitly.

As an aside, if you're using Postgres (which is what the other jar files in that directory are for), you should only use a single one of those files. See this page for which to use.
vainu siva
Greenhorn

Joined: Dec 08, 2007
Posts: 6
sorry,I cant get you.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42042
    
  64
If you want to use external library (like the Mysql driver) that comes in a jar file, you need to put it into the so-called classpath for the JVM to find it. On the command line, this is generally done by using a command like:

Note that I added the "." as a second entry to the classpath, so that any class hierarchy in the current directory is also found.
 
 
subject: class not found exception