Junior — Middle
What format and structure of code are packaged into a JAR file?
sobes.tech AI
Answer from AI
A JAR (Java ARchive) is an archive file that packages together:
- Compiled Java classes (.class files), organized in directories corresponding to packages.
- Resources (e.g., images, configuration files) needed by the application.
- Manifest file (META-INF/MANIFEST.MF) containing metadata about the JAR, such as the entry point (Main-Class).
The structure of a JAR file is similar to a ZIP archive with a specific organization:
/ (root of archive)
com/example/MyClass.class
resources/config.properties
META-INF/
MANIFEST.MF
A JAR file makes it convenient to distribute and run Java applications or libraries.