Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am wondering if I can refer to files inside JAR or ZIP files using URLs. I mean, without using a tool (such as the Java Jar utility) but just at the operative system level.

For example, if I have a file myfile in a Jar file myjar, I would like to be able to write something like:

ls -name 'jar:file:/myjar!/myfile'

and see listed the file myfile

The context of this question is that I need to load Prolog files that are zipped in JARs files, but currently I have not discovered how to do this with the console based Prolog interpreter I am using (YAP). In the hope that at the end the command for loading Prolog files will just submit the request to the operative system, I thought that I just need to find out the right way to refer to files inside JAR or ZIP files in such a way that the operative system understands what I am talking about (I am using OSX).

share|improve this question

1 Answer 1

The AVFS filesystem presents a view of the filesystem where every archive file /path/to/foo.zip is accessible as a directory ~/.avfs/path/to/foo/zip#. AVFS provides read-only access to most common archive file formats.

Install AVFS (it's provided by many distributions; it requires FUSE, which every modern unix supports). Run this command once and for all (you can run it from your ~/.profile):

mountavfs

And thereafter:

ls /path/to/my.jar\#/myfile
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.