In the process of reading any questions, welcome to communicate together
Email:[email protected]
qq:1494713801
1. Actually running the jar Package command is relatively simple: after entering the corresponding directory, execute Java-jar Xxx.jar!
2. But why can't the jar from MAVEN package or eclipse export run? The reason is simple, does not specify which class executes the main method, how to specify? Configuration file, there is a Meta-inf folder under the project folder, there is a MANIFEST.MF file under the Meta-inf folder, as long as you change the file.
3. The default content of this file is:
manifest-version:1.0
created-by:1.4.2 (Sun Microsystems Inc.)
Change it to
manifest-version:1.0
created-by:1.4.2 (Sun Microsystems Inc.)
Main-class:xxx.xxx.xxx.xxx
Attention:
Main-class the next X part is the package name. Class Name
Main-class: There's a space behind, and there's a blank line underneath.
4. After the content is changed, how do you make it into a jar package?
I tried to pack it directly with WinRAR and then change the suffix name, no,
Here's how it works:
Suppose your jar package is named Myjar.jar:
(1) First extract the Myjar.jar to Myjar (in the same layer folder) unzip myjar.jar-d Myjar
(2) Enter the Myjar folder, then enter the Meta-inf folder, change the Manifest.mf file,
Follow steps three.
(3) Save back to Myjar.jar the same level directory, then execute Jar UMF myjar/meta-inf/manifest. MF Myjar.jar
If there is no error, and the Xxx.tmp file is generated, the execution succeeds,
Open Myjar.jar and you can see that the MANIFEST.MF file has been changed to the appropriate file.
(4) Java-jar Myjar.jar can be executed in the current directory
"Deep Java" package project as jar package and run jar