https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html

JAR 文件性质

JAR files are packaged with the ZIP file format, so you can use them for tasks such as lossless data compression, archiving, decompression, and archive unpacking. These tasks are among the most common uses of JAR files, and you can realize many JAR file benefits using only these basic features.

JAR Files as Applications

You can run JAR packaged applications with the Java launcher (java command). The basic command is:

java -jar jar-file

The -jar flag tells the launcher that the application is packaged in the JAR file format. You can only specify one JAR file, which must contain all of the application-specific code.

Before you execute this command, make sure that the runtime environment has information about which class within the JAR file is the application's entry point.

To indicate which class is the application's entry point, you must add a Main-Class header to the JAR file's manifest. The header takes the form:

Main-Class: classname

The header's value, classname, is the name of the class that is the application's entry point.

For more information, see the Setting an Application's Entry Point section.

When the Main-Class is set in the manifest file, you can run the application from the command line:

java -jar app.jar

To run the application from the JAR file that is in another directory, you must specify the path of that directory: java -jar path/app.jar

Manifest.MF

When you create a JAR file, it automatically receives a default manifest file. There can be only one manifest file in an archive, and it always has the pathname

META-INF/MANIFEST.MF