db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajesh Kartha <kar...@Source-Zone.Org>
Subject Re: Can't find derby embedded driver when calling class is in a jar file
Date Mon, 23 Jan 2006 00:38:10 GMT

> ...
> 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.

 >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


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)


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


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

Hope the above helps.


View raw message