db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: Database in a jar starts from another dir
Date Sun, 08 Nov 2009 16:57:59 GMT
Fran├žois <francois.rappaz@unifr.ch> writes:

> Hi
> I have java classes and a database within the same jar. Using the connection
> string jdbc:derby:jar:(myfile.jar)mydatabase (now defined at comiled time) all
> works well if I start the application by double-clicking the jar or running the
> jar with java -jar myapp.jar in the directory where myfile.jar and derby.jar 
> are. In the manifest of the jar I have a class-path attribute with derby.jar.
> Now if I have a shortcut to the jar or in I run the apps from another directory
> the database is lost. For example, running 
> java -cp u:\docs ..\myfile.jar ch.my.package.MyMainClass does not resolve the
> problem.
> I could put a properties file with the connection string with the full path to
> the jar file in the connection string, but I would ask if there is another 
> solution.

Hi Fran├žois,

I think you could achieve what you want by using the classpath protocol
instead of the jar protocol. With myfile.jar in the classpath, try this


Hope this helps,

Knut Anders

View raw message