...

I have the derby jar files set in the classpath. This code has always worked fine from any programs run from the command line but when I package the code above into a jar file, it can't find the embedded driver for Derby anymore, although the code works fine with Oracle DB 7.x, Sybase etc. I tried to set the jar files as run-time parameters as :

java -cp .;./derby.jar program.jar or
java -cp %classpath% program.jar

to no avail.



Hi,

>
>java -cp .;./derby.jar program.jar or
>java -cp %classpath% program.jar
>

Maybe I did not fully understand the above, but did you mean running the main class from a jar file using something like

java -jar program.jar

with the manifest file of 'program.jar' having the 'Main-Class:' defined ? In that case, the Java classloader will ignore the CLASSPATH environment variable setting or the -cp command-line argument. It only loads classes from the main jar ('program.jar' in the above case) and those specified in the manifest file.

I think the following are some possible ways to make it working:

1) Have you tried adding the 'derby.jar' as an entry to the 'Class-Path' header of the Manifest file

Example:

Class-Path: lib/derby.jar
(note the path is with respect to the location of the jar being executed i.e 'program.jar' in this case)

http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html

2) Create one jar. I  found this interesting article at IBM developerWorks

http://www-128.ibm.com/developerworks/java/library/j-onejar/

3) Using the Fat Jar Eclipse Plugin - http://fjep.sourceforge.net/

Hope the above helps.

-Rajesh

Reply via email to