how to fix invalid or corrupt Jarfile?

只谈情不闲聊 提交于 2019-12-13 03:57:17

问题


I am working on a simple java project 'Hello world!'. So after creating my code I built it and created the Jarfile using maven:

mvn clean install package 

So my problem is when ever I try to run the executable Jarfile I get the following error message:

Error: Invalid or corrupt jarfile junit-1.2.jar

this is my pom.xml file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>


<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>


 <dependencies>

   <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13-beta-1</version>
   </dependency>

     </dependencies>

<build>
    <plugins>
        <plugin>
            <!-- Build an executable JAR -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>hello</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>


</project>

And this is my MANIFEST.MF file:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: jenkins
Created-By: Apache Maven 3.6.0
Build-Jdk: 1.8.0_191
Main-Class: hello

Thank you for your help.

来源:https://stackoverflow.com/questions/55610058/how-to-fix-invalid-or-corrupt-jarfile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!