Many Java developers use JAR files (Java ARchives) to distribute their applications. It is a nice form of distribution, because it is easy for the developer to make, and the end user can run it by simply double clicking on the JAR file.
I want to point out a simple fact that I’ve noticed many Java developers are unaware of, especially if they are fairly new to Java.
JAR files use the ZIP compression scheme.
Try it out! Take a JAR file and change the extension from .jar to .zip and you’ll see that your computer will allow you to browse through the contents without any trouble. In a lot of ways, this isn’t a good or a bad thing, just a fact.
If you know about this, though, you can use it to your advantage. For example, Java applications will often link to other JAR files in a way that is very similar to linking to a DLL or SO file. Sometimes, though, when I’m writing Java code, I will get an error saying my program can’t find a particular class, that I know ought to be in another JAR file. Because JAR files are just ZIP files, I can change the extension and go in and make sure that the JAR actually class of interest, to know if it really is missing the file, or just isn’t loading the JAR file correctly.
There’s a lot you can do with this knowledge, so I think it makes it something that all programmers ought to know about.
Do you have any thoughts on how this might be useful to developers? Leave a comment and let everyone know!
View Comments
blog comments powered by