“Invalid signature file” when attempting to run a .jar

后端 未结 21 1982
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 05:34

My java program is packaged in a jar file and makes use of an external jar library, bouncy castle. My code compiles fine, but running the jar leads to the following error:

21条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 06:16

    In case you're using gradle, here is a full farJar task:

    version = '1.0'
    //create a single Jar with all dependencies
    task fatJar(type: Jar) {
        manifest {
            attributes 'Implementation-Title': 'Gradle Jar File Example',  
                'Implementation-Version': version,
                'Main-Class': 'com.example.main'
        }
        baseName = project.name + '-all'
        from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
        exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' 
        with jar
    }
    

提交回复
热议问题