IntelliJ工件JAR文件:找不到或加载主类 [英] IntelliJ artifact JAR file: Could not find or load main class

查看:120
本文介绍了IntelliJ工件JAR文件:找不到或加载主类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IntelliJ中创建了一个JAR工件,并带有将JAR文件提取到目标JAR的选项.看起来像这样:

I created a JAR artifact in IntelliJ with option to extract JAR files to the target JAR. Look like this:

我正确填写了清单信息:

I filled the manifest information properly:

我用ZIP检查了JAR文件的内容,其中包含jar文件,正确填充的MANIFEST.MF和项目的.class文件.

I checked the content of the JAR file with ZIP and it contains the jar files, the properly filled MANIFEST.MF and the .class files for my project.

但是,如果我尝试运行它,它将丢弃一个错误:

But if I try to run it, it drops an error:

d:\Own_Tools\REF_Standalone\build>java -jar REF_Standalone.jar
Error: Could not find or load main class com.continental.ref.REFController

我非常确定它包含com \ continental \ ref \ REFController.class.

I am pretty sure it contains com\continental\ref\REFController.class.

您知道它出了什么问题吗?

Do you have any idea what went wrong with it?

谢谢: 莱万特

推荐答案

apache-commons.jar是经过数字签名的(您可以通过META-INF目录中的FILETEST.DSAFILETEST.SF告诉它).

apache-commons.jar is digitally signed (you can tell it by the FILETEST.DSA and FILETEST.SF in the META-INF directory).

打包人工制品jar时,这些文件被复制到新jar中,但是它们不包含新jar中其他类的签名.

When the artifact jar is packaged, these files are copied into the new jar, but they do not contain the signatures for other classes in your new jar.

这会破坏jar签名,并且出于安全原因,JVM不允许执行jar.

This breaks the jar signature and JVM doesn't allow the execution of the jar for the security reasons.

有关变通办法,请参见我的另一个答案(只需从apache-commons.jarapache-commons.jar中删除*.SF*.DSA文件重建工件).

See my another answer for the workaround (just delete *.SF and *.DSA files from apache-commons.jar and rebuild the artifact).

这篇关于IntelliJ工件JAR文件:找不到或加载主类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆