IntelliJ build wrong JAR: Could not find or load main class

十年热恋 提交于 2019-12-04 07:31:02

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

Not sure what was with IntellJ, but I rebuilded artifacts again and it was ok.

hadoop jar <Jar-name>
java -jar <Jar-name>

Everything is working fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!