Errors With Jar file...

B

balgach

Hello all,

I am trying to jar up my classes for easy access, the problem is as
follows...

my application depends on teh postgresql jdbc driver (pg73jdbc.jar)
now when i compile and run as classes with this jar file in the
CLASSPATH, everythign works fine all well and good. When i jar the
classes up, i get a ClassNotFound Exception when looking for the JDBC
drivers. (even though it is in my class path)

ive even tried:

java -jar myapp.jar pg73jdbc.jar

and get the same errors. is there something i am missing when creating
the jar file? can i somehow include the pg73jdbc.jar file with my jar
file, to just have one large jar file? Thanks.


Cheers,
Adam.
 
T

Thomas Fritsch

Hello all,

I am trying to jar up my classes for easy access, the problem is as
follows...

my application depends on teh postgresql jdbc driver (pg73jdbc.jar)
now when i compile and run as classes with this jar file in the
CLASSPATH, everythign works fine all well and good. When i jar the
classes up, i get a ClassNotFound Exception when looking for the JDBC
drivers. (even though it is in my class path)

ive even tried:

java -jar myapp.jar pg73jdbc.jar

and get the same errors. is there something i am missing when creating
the jar file? can i somehow include the pg73jdbc.jar file with my jar
file, to just have one large jar file? Thanks.


Cheers,
Adam.

Hi Adam!

You have to specify an additional Class-Path in your main jar-file's
manifest-file. It is described in
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#JAR Manifest (look
for "Class-Path" there).

You can *not* use the "-classpath" option or the "CLASSPATH" environment
variable, when
starting it with "java -jar ...", simply because these classpath settings
are not evaluated then
This peculiar feature is documented in
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html#-jar (see the
last sentence there)

There are also some threads in this newsgroups concerning that topic.
You can find them with
http://groups.google.de/groups?as_q=jar+Class-Path+manifest

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top