You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Philippe Poulard <Ph...@sophia.inria.fr> on 2005/05/17 10:21:11 UTC
[VFS] classpath lookup for opaque JAR
hi,
i'm still using VFS, and I'm working rigth now with jar resources
an URI like this :
jar:myJar.jar!/path/to/resource
will work, whereas when using traditional java.net.URL parser it fails
because such URI is opaque
fine !
however, the URI is resolved like this :
jar:file:///path/to/current/dir/myJar.jar!/path/to/resource
mmmh, I would prefer that instead endorsing the current dir, it would
lookup in the classpath for the library that has this name
any advice ?
--
Cordialement,
///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [VFS] classpath lookup for opaque JAR
Posted by Philippe Poulard <Ph...@sophia.inria.fr>.
Mario Ivankovits wrote:
> Philippe Poulard wrote:
>
>> an URI like this :
>> jar:myJar.jar!/path/to/resource
>> is resolved like this :
>> jar:file:///path/to/current/dir/myJar.jar!/path/to/resource
>>
>> I would prefer that instead endorsing the current dir, it would lookup
>> in the classpath for the library that has this name
>
> If you would like to access a resource within a jar which is in your
> classpath you could use
>
> res:path/to/resource
>
> notice the missing starting "/"
Great ! This is exaclty what I was looking for
>
> This will search the resource using javas default
> ClassLoader.getResource(name)
>
> However, once resolved it will be expanded to its full location.
That's not a problem
> e.g. wenn you search for
>
> res:META-INF
>
> you might get
>
> jar:file:///usr/java/jdk1.5.0_03/jre/lib/rt.jar!/META-INF
>
> You cant directly specify the jar filename where this META-INF should be
> sourced.
>
> If you have a special directory where you place your jars and put THIS
> directory in your classpath (e.g. /path/to/my/jars) then it should be
> possible to use
>
> FileObject fo = VFS.getMananger.resolveFile("res:anyjar.jar");
> FileObject root = VFS.getManager().createFileSystem(fo);
>
> due to a bug in VFS you cant use "jar:res:anyjar.jar!/" - but this will
> be fixed.
>
>
> But notice the difference:
> The first will lookup the resource in any jar/path on your classpath as
> it is intended by the java ClassLoader.getResource.
> The second is a "hack" to specify exactly which jar should be used. You
> might get problems whith such a solution as in an webapp the WEB-INF/lib
> directory is NOT in your classpath and you cant manage to get it in
> there (as far as I know). But I think its the first solution you looked
> for, isnt it?
>
Sure
I'll try all the stuff and report troubles, if any
thanks
--
Cordialement,
///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [VFS] classpath lookup for opaque JAR
Posted by Mario Ivankovits <ma...@ops.co.at>.
Philippe Poulard wrote:
> an URI like this :
> jar:myJar.jar!/path/to/resource
> is resolved like this :
> jar:file:///path/to/current/dir/myJar.jar!/path/to/resource
>
> I would prefer that instead endorsing the current dir, it would lookup
> in the classpath for the library that has this name
If you would like to access a resource within a jar which is in your
classpath you could use
res:path/to/resource
notice the missing starting "/"
This will search the resource using javas default
ClassLoader.getResource(name)
However, once resolved it will be expanded to its full location.
e.g. wenn you search for
res:META-INF
you might get
jar:file:///usr/java/jdk1.5.0_03/jre/lib/rt.jar!/META-INF
You cant directly specify the jar filename where this META-INF should be
sourced.
If you have a special directory where you place your jars and put THIS
directory in your classpath (e.g. /path/to/my/jars) then it should be
possible to use
FileObject fo = VFS.getMananger.resolveFile("res:anyjar.jar");
FileObject root = VFS.getManager().createFileSystem(fo);
due to a bug in VFS you cant use "jar:res:anyjar.jar!/" - but this will
be fixed.
But notice the difference:
The first will lookup the resource in any jar/path on your classpath as
it is intended by the java ClassLoader.getResource.
The second is a "hack" to specify exactly which jar should be used. You
might get problems whith such a solution as in an webapp the WEB-INF/lib
directory is NOT in your classpath and you cant manage to get it in
there (as far as I know). But I think its the first solution you looked
for, isnt it?
---
Mario
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org