*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 41062
    
  43
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: 41062
    
  43
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: 41062
    
  43
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class not found exception
 
Similar Threads
using external jar files
java.lang.NoClass DefFoundError: while resolving class
System.out.println("i -->"+i); This statement give runtime error on linux
jdbc connection with mysql on unix
sql connection with java