Under Linux Execute Jar file method: Enter file directory under command line,execute Java-jar file.jar i.e.Can also create a launcher on the desktop, fill in the command bar related commands: Java-jar/file path/file.jar, so that the desktop double-click to open the Jar file
Create an executable jar file package in detail: The jar file is Java Archive file, as implies, its application is related to Java, is a Java document format. The JAR file is very similar to a zip file--exactly, it is a zip file, so call it a file package. The only difference between a jar file and a ZIP file is that it contains a meta-inf/manifest in the contents of the jar file. MF file, this file is created automatically when the JAR file is generated. For example, if we have some files with the following directory structure:
==
'--Test
'--Test.class
Compress it into a zip file test.zip, the internal directory structure of this zip file is:
Test.zip
'--Test
'--Test.class
If we use the JDK jar command to call it a jar package Test.jar, the internal directory structure of this jar file is:
Test.jar
|--Meta-inf
| '--MANIFEST. Mf
'--Test
'--test.class
To create the executable jar package, you need to use the jar command with the CVFM parameter, as an example of the test directory above, the command is as follows: JAR CVFM test.jar MANIFEST.MF test, Test.jar and MANIFEST.MF here two text The corresponding parameters F and M, respectively, and their plays are in MANIFEST.MF. Because to create an executable jar package, it is not sufficient to specify a MANIFEST.MF file, because manifest is a feature of the jar package, both the executable jar package and the non-executable jar package contain manifest.The key is to execute the MANIFEST of the JAR file package, which contains the Main-class. This is written in MANIFEST in the following format: Main-class: Executable main class full name (including package name)
For example, assuming that the test.class in the previous example belongs to the Test package and is an executable class (which defines the public static void Main (string[]) method, then this MANIFEST.MF can be edited as follows: Main-clas S:test. Test, this manifest.mf can be placed anywhere, or it can be another file name, only need to have main-class:test. Test line, and the line ends with a carriage return character. After creating the MANIFEST.MF file, our directory structure becomes:
= =
|--Test
| '--Test.class
'--MANIFEST.MF
At this point , you need to go to the parent directory of the test directory to use the JAR command to create the jar file package. That is, in the directory tree using = = In the directory, use the following command: Jar CVFM test.jar MANIFEST.MF test
After that, the Test.jar,test.jar is created in the = = Directory, which is the jar file package that executes. The runtime only needs to use the Java-jar test.jar command.
It is important to note that the JAR package created must contain the complete directory structure corresponding to the Java package structure. The class specified by Main-class must also be a complete class name that contains the package path, as in the previous example, test. Test, and Java can be used to run this class before it is called a JAR file, i.e. Java test in the previous example. Test can be run correctly (of course, in the CLASSPATH correct case).
How Linux executes jar files how to hit executable jar packages