Results 1 to 8 of 8

Thread: class not found

  1. #1
    meong is offline Member
    Join Date
    Sep 2010
    Posts
    4
    Rep Power
    0

    Default class not found

    Hello, i'm newbie in java

    trying to make application that connect to the mysql database, it works fine in my pc, but not in the server
    this line appeared :
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

    i don't install j2sdk on the server, just the jre, i've put the mysql-connector-java-3.0.17-ga-bin.jar on the lib of the jre,
    I also copy the driver on the same folder as the java app,
    set the environment path of the windows to C:\myserver
    the folder where the java app and the connector
    restart the server, but it still happens
    why is this happening?

    thx

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    Is this a webapp?

  3. #3
    meong is offline Member
    Join Date
    Sep 2010
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Is this a webapp?
    no it's not,
    it's a desktop app, console one

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    It's just you mentioned a server.

    Don't stick the driver jar in the jre lib, that's just plain wrong.

    Is your app a jar file?

  5. #5
    meong is offline Member
    Join Date
    Sep 2010
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    It's just you mentioned a server.

    Don't stick the driver jar in the jre lib, that's just plain wrong.

    Is your app a jar file?
    my app is a class file
    so where to put it right?
    i also put the jar file in the same folder as the app C:\myserver
    and set the system environtment variables path to ....;C:\myserver
    but it still doesn't work

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    Put it with the class file.
    And run using the -cp option, listing any required jar files (and .).

    You don't set system paths...that is very bad practice. What if you had multiple apps which used different versions of a particular dependency? You'd have problems.

    So use -cp.

  7. #7
    meong is offline Member
    Join Date
    Sep 2010
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Put it with the class file.
    And run using the -cp option, listing any required jar files (and .).

    You don't set system paths...that is very bad practice. What if you had multiple apps which used different versions of a particular dependency? You'd have problems.

    So use -cp.
    ok it works
    thx Tolls for the help
    Gbu

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

Similar Threads

  1. Class not found Exception
    By surendra in forum Java Servlet
    Replies: 8
    Last Post: 06-09-2011, 12:52 PM
  2. Class Not found
    By jitendra in forum AWT / Swing
    Replies: 5
    Last Post: 02-26-2010, 10:55 AM
  3. main class not found
    By abhijit in forum Networking
    Replies: 3
    Last Post: 10-01-2009, 09:05 AM
  4. No Class Def Found Error:
    By fithous in forum Java Applets
    Replies: 0
    Last Post: 04-02-2009, 05:30 PM
  5. No Class Def Found Error:
    By wrap23 in forum New To Java
    Replies: 9
    Last Post: 10-02-2008, 04:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •