IntelliJ artifact JAR file: Could not find or load main class

Levente :

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

enter image description here

I filled the manifest information properly:

enter image description here

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

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

Do you have any idea what went wrong with it?

Thanks: Levente

CrazyCoder :

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

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.

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

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=105805&siteId=1