Week 84 — What is a JAR file?

Question of the Week #84
What is a JAR file?
11 Replies
Eric McIntyre
Eric McIntyre4mo ago
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.
java --class-path yourjar.jar com.example.myproject.MyClass
java --class-path yourjar.jar com.example.myproject.MyClass
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
Eric McIntyre
Eric McIntyre4mo ago
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
Eric McIntyre
Eric McIntyre4mo ago
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
Eric McIntyre
Eric McIntyre4mo ago
A JAR file is just a ZIP file that contains compiled Java code (*.class).
Submission from yuyu52710
Eric McIntyre
Eric McIntyre4mo ago
Jar files are collection of .class file that are the compiled classes of java file
Submission from ayandotjava
Eric McIntyre
Eric McIntyre4mo ago
Its a packaging file used to agregate java classes and resources and libraries which can be run by java virtual machine
Submission from mpfx1
Eric McIntyre
Eric McIntyre4mo ago
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
Eric McIntyre
Eric McIntyre4mo ago
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
Eric McIntyre
Eric McIntyre4mo ago
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
Eric McIntyre
Eric McIntyre4mo ago
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
Eric McIntyre
Eric McIntyre4mo ago
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
Want results from more Discord servers?
Add your server