Jar run error


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Jar run error

  1. #1
    Join Date
    May 2006
    Posts
    2

    Unhappy Jar run error

    Hello i'm new here on this forum so excuse me if i do something wrong.

    I have a question for a time i program in java my first real project is at a beta fase but when i compile him to an jar file and run him with the following :
    java -jar project.jar

    i get an error (This one):

    java.lang.ClassNotFoundException: org.gjt.mm.mysql.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 Reparatie.Main.<init>(Main.java:34)
    at Reparatie.Main.main(Main.java:46)

    I use an mysql driver manager (mysql-connector-java-3.1.12-bin.jar).
    I program in Netbeans IDE 4.1

    But i don't know why i get this error when i run my program in netbeans he runs correctly.

    Can anyone help me please !

    If you need some code to help please ask....

    Greetz ,

    Pielie

  2. #2
    Join Date
    Mar 2004
    Posts
    635
    is the mysql jar file included in the same directory as your project jar? If not, then is listed anywhere in your classpath or in your jsdk extensions directory?

    I'm guessing the mysql jar isn't included in a classpath anywhere. It works when running from Netbeans because it automatically sets the classpath when you compile to include any extra jar files you've set it up with.

    Include "mysql-connector-java-3.1.12-bin.jar" in the same directory where you're running your project jar from and it should run.

  3. #3
    Join Date
    May 2006
    Posts
    2
    sorry i tried that also but it won't work, i also tried the command in cmd set classpath="path to jar file" but also that doesn't seems to work

  4. #4
    Join Date
    Feb 2006
    Location
    Cologne - Germany
    Posts
    271
    there are several methods to enshure your classpath:
    easy but dirty is to put the mysql jar into the ext-folder of your jre and java installation folders. then java will definitely find it.
    better is to use the classpath in the java command:
    java -cp ".;mysql.jar;project.jar" -jar project.jar
    if youre using windows, you cann set your classpath in system/systemvariables

Similar Threads

  1. 'On Error Goto' versus 'Try, Catch, Fail'
    By clarence_rollins in forum .NET
    Replies: 21
    Last Post: 09-11-2002, 11:32 AM
  2. run time error "3633"???
    By DH in forum VB Classic
    Replies: 1
    Last Post: 11-07-2001, 01:43 PM
  3. Internal Server Error 500 on IIS
    By John in forum ASP.NET
    Replies: 0
    Last Post: 08-16-2001, 12:06 PM
  4. Run time error -2147220992 Library Not Registered
    By Melissa Brown in forum VB Classic
    Replies: 6
    Last Post: 02-12-2001, 10:26 AM
  5. Run time error
    By antonio in forum VB Classic
    Replies: 0
    Last Post: 09-27-2000, 02:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center