1. Problem description
After packaging Maven project into jar package in Ubuntu environment, run the following instructions:
1 $ java -jar my.jar
An error occurred:
1 Error: Invalid or corrupt jarfile my.jar
2. Problem analysis
First, make sure that the jar package is not damaged during transmission
If the jar package is not damaged, it is most likely that the entry information is misconfigured or lost
3. Solutions
Case 1: the configuration of information in manifest.mf file in meta-inf folder in Java directory is wrong
Open the manifest.mf file and observe whether the main function entry corresponding to main class: is correct, for example:
1 Manifest-Version: 1.0
2 Main-Class: com.myproject.Main
Case 2: the information in manifest.mf file is configured correctly, but the program entry cannot be found correctly
In this case, the entry information may be lost in the packaging process, there are too many entries, the main entry is not specified, or the entry cannot be successfully found for other reasons. You can use the – CP instruction to forcibly specify the program entry. The instruction is as follows:
1 $ java -cp my.jar com.myproject.Main
After finding the entry, the program can run smoothly
Similar Posts:
- Run jar file under Linux system, prompt: no main manifest attribute, in xxx.jar [How to Solve]
- Webpack 4 : ERROR in Entry module not found: Error: Can’t resolve ‘./src’
- [How to Solve] diff: /../Podfile.lock: No such file or directo
- error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
- Using idea and maven, there is an error: (4, 21) Java: there is no problem with the package javax.servlet
- NoClassDefFoundError: javax / activation / datasource solution
- [Solved] Exception in thread “main” java.lang.IllegalStateException: Failed to read
- signer information does not match signer information of other classes in the same package
- Solve the error reported by eclipse project: unbound classpath container
- Intellij Pack the jar file error: “java.lang.SecurityException: Invalid signature file digest for Manifest main attrib