How do JARs handle Windows vs. *nix file systems?
So my understanding is that JARs can have a hierarchy of files and folders. So if I want to JAR up the following file structure:
someDir/ anotherDir/ yetAnotherDir/ widget.java foo.java someFile.jpg anotherFile.qfx
The convention I'm using i开发者_如何学Cs the Linux forward-slash ("/"). On Windows it would be a backwards slash ("\") to demarcate file paths.
Is it that Java JARs up file hierarchies into a uniform, platform-independent structure, so that the same JAR can be run off a Windows and Linux machine alike? Or do JARs prefer a particular schema (Windows or Linux) for file paths and use that under the hood?
Thanks!
Is it that Java JARs up file hierarchies into a uniform, platform-independent structure, so that the same JAR can be run off a Windows and Linux machine alike?
Yes.
The same jar can run in both Windows and Linux based systems. The difference in the folder separator has nothing to do with it. Actually Windows understand both forward and backwards slash as a separator.
It just seemed to be an answer instead of a comment!
AFAK Jar is almost the same as Zip. If I'm not mistaken it's exactly based on Zip. So that's why it's platform independent. I've even tried unzipping and zipping a jar again and it works.
Software developers generally use .jar files to distribute Java applications or libraries, in the form of Java class files and associated metadata and resources (text, images, etc.). JAR files build on the ZIP file format. - See http://en.wikipedia.org/wiki/JAR_(file_format)
精彩评论