Building artifacts with "org.eclipse.paho.client.mqttv3" library causes "Could not find or load MainKt
Answered
Hi,
I am trying to build my project to a single jar with artifacts in intellij. I need the org.eclipse.paho.client.mqttv3 java library included.
I added the library via modules -> dependencies. I added the library jar as "extracted directiory" in artifacts. When I run the builded jar on cmd with "java -jar myproject.jar" the programm stops and displays "Error: Could not find or load MainKt".
My code works when running directly in intellij. I also use other librarys in my builded jar without any problems.

Thank you for your help.
Please sign in to leave a comment.
@razorneck could you please provide a project example?
@Petr Rastegaev It think I got the same problem describe in the lates comments of https://blog.jetbrains.com/idea/2010/08/quickly-create-jar-artifact/
I am trying to build an Uber jar with the help of intellij artifacts. It seems that one of my libraries has his own MANIFEST files which overwrite my MANIFEST file. Because of that the jar doesn't now where to start (name of main class).
The library causing my issues is org.eclipse.paho.client.mqttv3-1.2.1.jar
Thank you for your help
Alright I found a workaround. I delete those Manifest files afterward in my builded jar. I use:
zip -d Code.jar 'META-INF/*.SF' 'META-INF/*.RSA' 'META-INF/*SF'
Next I need to find out how to exclude those files from the build process.