Skip to content

Nested jar: URI

The format of the jar: URI scheme is simply defined to be jar:<url>!/[<entry>].

Is it possible to “nest” two such URIs together and refer to a file inside an archive inside an archive this way? Something like:


This should designate /file inside an archive jar:!/archive, that is /archive found in a file provided by However, URL.openConnection throws an exception: no !/ in spec

I also cannot replace ! with %21 since that makes the jar: URI invalid, and I am not aware of any escaping that could be performed. Is this somehow possible? Or, as a more generic question, is it possible to store a URI with !/ inside <url> so that it is preserved?


As it is stated in the source code does not handle nested Jar URIs.

Your example jar:jar:!/archive!/fileis parsed as entry archive!/file in the archive jar: The latter is not a valid jar URI. You can not either escape the !/ sequences, because the text after jar: and before !/ must be a valid URI without any translation.

You can of course provide your own URLConnection implementation that supports nested Jar URIs.