• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class not found exception

 
vainu siva
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

How did you add the jar file to your classpath?
 
vainu siva
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry,I cant get you.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic