Reputation: 2426
First of all I'm not able to produce a .jar with IntelliJ without using Artifacts and I don't understand why. I make my project, build it, run it, make module but none of that produce de .jar in out directory... Maybe the reason is that I never wait to then end of the run and always interrupt with alt+F2 because the program is very long to run entirely, it's a bot.
So then I try to produce .jar using Artifact function in IntelliJ but it produces a .jar that I can't run :
-java prgr.jar
returns Error: Could not find or load main class prgr.jar
and -java -jar prgr.jar
returns no main manifest attribute, in prgr.jar
So I got few questions given that my program runs perfectly when I run the main class from IntelliJ :
What is the difference between commands : -java prgr.jar
and -java
-jar prgr.jar
What is the MANIFEST.MF and how to use it ?
How can I do to produce a .jar that I can run from a shell ? How to use the artifact function properly, what files do I have to put and where in order to make it work ?
Edit : I just saw that I need the MANIFEST.MF but how do I tell the .jar where to find the MANIFEST ?
Upvotes: 1
Views: 4153
Reputation: 339
If you include any signed JARs in your app and then use IntelliJ to build artifacts, it will extract the JARS and bundle them with your compiled output.
This then causes a JAVA security exception. I've seen this with Eclipse Paho and Bouncy Castle which are signed.
You can check if any of the library JARs you are using are signed using the jarsigner tool.
jarsigner -verify -verbose <path to library JAR>
Change your IntelliJ artifact setup so that these get bundled as libraries instead of being extracted. Extraction invalidates the certificate as you'd expect.
Try creating a dummy project with just Main. Add 1 library JAR (that you are trying to build with) at a time. Build an output JAR each time until Main breaks. That's how I found this.
IntelliJ should warn you.....
Upvotes: 2
Reputation: 2426
I was finally able to solve my problem thank to this thread Wrong Manifest.mf in IntelliJ IDEA created .jar the most upvoted answer. I think it's a bug in IntelliJ that needs to be fixed : when the MANIFEST.MF
is in main/java
instead of /main/ressources
it isn't included in the final .jar which mean that the .jar only contains the manifest relative to the external libraries but not the manifest that tells what is the main class.
Upvotes: 1