Difference between java class and jar

2019-03-08 13:39发布

问题:

What is the difference between a java class file and a jar file?

回答1:

A Jar file is an Zip archive containing one or multilple java class files. This makes the usage of libraries (consisting of multiple classes) more handy. Directories and Jar files are added to the classpath and available to the ClassLoader at runtime to find particular classes inside of it.



回答2:

A JAR file has many files into it. We generally use .jar files to distribute Java applications or libraries, in the form of Java class files and associated metadata and resources (text, images, etc.). you can say JAR = Java ARchive.

All java files are compiled into class files and then we use that class file not the .java file. A class is a construct that is used as a blueprint to create instances of the class.

See Wikipedia for more information: Wikipedia for JAR and Wikipedia for class



回答3:

A java file contains Java code. A Java file is compiled to produce a class file that can be loaded by the JVM. The contents of a class file are rather well explained here. A Jar file is an archive of otherfile, most likely class files.



回答4:

JAR file is the compressed file format. You can store many files in a JAR file. JAR stands for the Java Archive. This file format is used to distribute a set of java classes. This file helps you to reduce the file size and collect many file in one by compressing files

a Class is explained here



标签: java class jar