java - Exporting jdbc in project jar file -


I have a Java program that connects to MySQL and some updates work. Now I want to export the application as a jar file with the JDBC package. I am doing something like this ( pwd ) for all the following commands: / home / tnp / updateServer_SRC / bin / ):

  $ echo $ CLASSPATH:. / Home / TNP / UpdateServer_SRC / Bin / update / server: /home/tnp/UpdateServer_SRC/bin/update/server/jdbc.jar ignore $ Java update.server.Main latest: 12177: Ignoring 12172: Ignoring 12173: Ignore 12,174: Ignore 12175: 12176 Ignore: 12177 ^ c  

So far goo, I'm leaving the execution because it displays them in one while loop in every 30 minutes.

Now, creating the jar file:

  $ jar cvf added by adding sth.jar update manifest: update / update in / server Adding: Update / Server / (in = 0) (out = 0) (stored 0%): / Server / Client (in = 1866) (in = 0) (in = 0) (out = 0) Jdbc.jar (= 876733) (out = 1021) (deflected 45%) adding: update / server / homepage Adding (deflected 4%): Update / Server / Update Last5.class (= updated in: / Server / Notice category (= 2715) (in class = (= 2046) (out = 1184) (defiled 42%) = 837707) Update) = (9 7) (out = 1521) (deflated 43%)  

The jar file was created Try running it:

  $ Java -jar sth.jar No main manifest attribute, in sth.jar  

Oh, pwd is not in my current class path, I try again :

  $ java -cp sth.jar update.server.Main latest: 12177 java.lang.ClassNotFoundException: java.net.URLClassLoader $ 1 .r on com.mysql.jdbc.Driver un (URLClassLoader.java:366) java.security.AccessController.doPrivileged (Native Method on java.net.URLClassLoader $ 1.run (URLClassLoader.java:355) java.net.URLClassLoader.findClass) (on URLClassLoader.java : 354) on java.lang.ClassLoader.loadClass (on java.lang.ClassLoader.loadClass (ClassLoader.java:424) sun.misc.Launcher $ AppClassLoader.loadClass (Launcher.java:308) on ClassLoader.java:357) on Java.lang.Clang.forName0 (Basic Law) on java.lang.Class.forName (Class.java:190) on update.server.UpdateLast5.run (UpdateLast5.java:18) at java.lang.Thread.run (Thread.java:724) formula exception "Thread -0" update.server.UpdateLast5.run (UpdateLast5.java:40) java.lang.NullPointerException (Thread.java:72 4 at java.lang.Thread.run )  

And this stacktrace is thrown. I looked at it:

In the case of Jars, -cp and - cascus logic and % CLASSPATH% Environmental variables are ignored.

And I need to manually modify the MANIFET.MF file, and recreate the jar. But the reply given above says that class-path should be relative to my own jar file ( sth.jar ) and does not mention what to do about bundle jar files.

How do I import JDBC in my package so any help to work as a result of jar file "Normally" will be appreciated.

Problem solves currently using the following MANIFEST file:

  Manifest-Version: 1.0 Build-By: 1.7.0_25 (Oracle Corporation) Main-Class: Update Rider. Main class-path: JDBCer  

and sth.jar . jdbc.jar is inserted in the same directory as

.

Comments