-1

Hello I am developing a smaill Java Desktop Application using jDeveloper 11.1.2.4. My application is trying to connect to mysql DB. Everyting is fine with my application. It is running and getting data form mysql DB when I am running this application from jDeveloper(Means if I right click and hit run it is running). Finally I created an executable jar of my application. When I am trying to run this jar am getting the following execution.

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at java.net.URLClassLoader$1.run(Unknown Source)
        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.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.wipro.ConnectionProvider.getMySqlConnectionOnServer(ConnectionPro
vider.java:25)
        at com.wipro.KPISFrame.generateAutoMonitorList(KPISFrame.java:118)
        at com.wipro.KPISFrame.getDataForTable(KPISFrame.java:91)
        at com.wipro.KPISFrame.jbInit(KPISFrame.java:69)
        at com.wipro.KPISFrame.<init>(KPISFrame.java:44)
        at com.wipro.AutoMonitorApp.<init>(AutoMonitorApp.java:11)
        at com.wipro.AutoMonitorApp.main(AutoMonitorApp.java:31)
null

I have added mysql connecter jar in my jdeveloper manage libraries

enter image description here

and my project Libraries and classpath.

enter image description here

and it is showing my jar deployment profile

enter image description here

Still when am trying to run this executable jar am getting the above error. Please help.

Thanks in advance

Abdul
  • 1,130
  • 4
  • 29
  • 65
  • Open the created JAR file with any ZIP-Tool. Take a look at the manifest file. Check if the MySQL-JAR is in same place as declared in the manifest file. – Ben May 13 '15 at 12:23
  • thanks for you time. I opend the manifest file It contains the following – Abdul May 13 '15 at 12:52
  • Manifest-Version: 1.0 Main-Class: com.wipro.AutoMonitorApp – Abdul May 13 '15 at 12:52
  • In my manifest file there is no entry for mysql connector jar – Abdul May 13 '15 at 12:54
  • See my answer. The manifest file (for a executable JAR) should contain CLASS-PATH (when external libs are used). – Ben May 13 '15 at 12:55
  • Yes I checked your answer. Am creating this executable jar file from jdeveloper. Can you please give me a link to any post to create a executable jar. Thank you – Abdul May 13 '15 at 12:58
  • This is normally done **automatically** by your IDE (JDeveloper in our case). I do not have any experiences with JDeveloper. But there should be an option in JDeveloper. – Ben May 13 '15 at 13:00
  • Okay let me check. Thank you very much. – Abdul May 13 '15 at 13:03

2 Answers2

0

I created an answer to add an Image.

My comment was:

Open the created JAR file with any ZIP-Tool. Take a look at the manifest file. Check if the MySQL-JAR is in same place as declared in the manifest file

So, you have to check the following:

enter image description here

This manifest file was automatically generated by NetBeans, for this sample project. This project does only have one external dependency (MySQL).

EDIT:
Another way to start your Application is via CommandLine (or script), like (only example):

java -classpath "lib/mysql_lib.jar;your_app.jar" com.package.Main_Method_Class

Ben
  • 3,378
  • 30
  • 46
-1

See if checking the "deploy by default" checkbox in your library definition helps include the JAR in your application's jar. https://i.stack.imgur.com/JZTxX.png

Shay Shmeltzer
  • 3,693
  • 1
  • 13
  • 9
  • 1
    I tried with your suggestion . But same thing. It has not included in my executabel jar. Please hlep. – Abdul May 14 '15 at 05:07