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

1

6

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

Seismic answered 27/2, 2019 at 15:1 Comment(4)
pretty sure? It either does or it does not. Open the JAR and find the .class file. Make sure it's in the correct package path.Nonintervention
100% sure, I copied this path from the opened jar file: com\continental\ref\REFController.classSeismic
@Seismic > "I checked the content of the JAR file with ZIP and it contains the jar files". What does it mean? Do you have jars inside jar and expect it to work?Odlo
Yes, I followed the wizard of IntelliJ. It compressed the MANIFEST file, the compiled output and the library jar files into one jar.Seismic
O
2

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).

Odlo answered 27/2, 2019 at 21:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.