Hi,

I use the following code to get the path of the jar-file the
applications is running from:
> getClass().getProtectionDomain().getCodeSource().getLocation()

lg Clemens

2010/12/14 Thomas Mueller <[email protected]>:
> Hi,
>
> H2 can't currently load a database from the classpath (at least I
> don't currently know a direct way). However, if you run your
> application from a jar file, there is a way to get the name of the jar
> file. For example, if you run H2 as a jar file, then you can use:
>
> drop alias getJar;
> create alias getJar as $$
> String getJar() throws Exception {
>  return org.h2.Driver.load().getClass().getClassLoader().
>  getResources("org/h2/Driver.class").nextElement().toString();
> }$$;
> call getJar();
>
> For me, the result is:
> jar:file:/Users/thomasm/Downloads/h2/bin/h2-1.2.143.jar!/org/h2/Driver.class
>
> I think there is a second way to get the same result, but I forgot it.
>
> Once you know the jar file name, you can use
> http://h2database.com/html/features.html#database_in_zip
>
> Regards,
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups "H2 
> Database" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/h2-database?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to