Week 84 — What is a JAR file?
Question of the Week #84
What is a JAR file?
11 Replies
A JAR (Java archive) file is essentially a zip file containing compiled classes, resources and metadata.
JARs can be put on the classpath (or modulepath) using the
--class-path
(or --module-path
) option telling Java to load classes from the listed JARs.
If a JAR contains a Main-Class
element that points to a class with a main method, that JAR can be executed using the command java -jar yourjar.jar
. This loads the main class from the JAR file named yourjar.jar
, executes the main method and loads any other necessary classes on the way.📖 Sample answer from dan1st
A file that brings together multiple classes and Java files into one file for distribution and use as a program.
A prime example is a Minecraft mod, where classes are compiled into a .jar to be used and read by the client.
Submission from theawesomeguy47
A JAR is an archive file, much like a ZIP or a RAR file, that contains compiled classes and resources that are necessary for a java application at runtime when the JAR file is included in the classpath runtime command line argument.
Submission from psycotrompus
A JAR file is just a ZIP file that contains compiled Java code (*.class).
Submission from yuyu52710
Jar files are collection of .class file that are the compiled classes of java file
Submission from ayandotjava
Its a packaging file used to agregate java classes and resources and libraries which can be run by java virtual machine
Submission from mpfx1
Jar file is an application that contains the byte code that can be readen by the JVM and run those code to perform the tasks
Submission from waifu.janna
A Java archive file - contains Java code compiled to Java bytecode, which can then be executed in a jvm. It is the form Java executables are usually distributed/deployed in
Submission from elspon
A JAR file means Java Archive and is like s ZIP file of mainly Java classes.
You have two ways of create JAR files:
jar -cvf file.jar
jar — create —verbose —file file.jar
Submission from navatante
It is a java archive used for storing java classes and the associative meta data and resources into a file for distribution
Submission from elvadernator
A JAR file is a file with the ".jar" extension, standing for "Java archive", it can store Java classes, resources, and a MANIFEST.MF file, which can be used to describe the jar file as well as make it executable.
⭐ Submission from public_static_void_main_args