DEV Community

Discussion on: What is a jar?

Collapse
 
thorstenhirsch profile image
Thorsten Hirsch

Exactly. JARs can be libraries (no entry point) as well as applications, in which case there hast to be a main method as entry point... and I think application JARs also need a manifest file, which mentions the entry point explicitly (e.g. in case there are more than one main methods).

Why not just one file format? Actually it is one file format. The format is: a zip container. The file extension actually is not that important... it's more like a hint, but it does not define the file format or type. The first bytes of a file define its type, see Wikipedia.

And lastly: well a single file is easier to handle than hundreds of files, so they've put it in a container. Maybe you ask: why a ZIP? I think it's a good choice: it's widespread (available on all operating systems), it's free to use (no patents), and it has nice features like optional compression. Optional? Yes, you can use a ZIP container without compressing the files. And I don't think that compiled java class files can be compressed very much, so compression is definitely not the main reason for why they've chosen ZIP.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

This is an excellent analysis thank you I learned alot today 😁