Error prompt: Invalid or corrupt jarfile xxx.jar when packaging Maven project under Ubuntu

1. Problem description

An error occurred:

Error: Invalid or corrupt jarfile my.jar

Second, the problem analysis

First of all, we must ensure 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 the entry information has been lost.

Third, the solution

Case 1: The information in the MANIFEST.MF file in the META-INF folder in the java directory is incorrectly configured.

Open the MANIFEST.MF file and observe whether the corresponding main function entry behind Main-Class: is correct, for example:

Manifest-Version: 1.0
Main-Class: com.myproject.Main

Case 2: The information in the MANIFEST.MF file is configured correctly, but the program entry cannot be found correctly.

At this time, the entry information may be lost during 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 command to force the entry of the program. The instructions are as follows:

$ java -cp my.jar com.myproject.Main

After finding the entrance, the program can run smoothly.

Ubuntu Maven project packaging prompt Error: Invalid or corrupt jarf

Guess you like

Origin www.linuxidc.com/Linux/2020-04/162858.htm
Recommended