I have java project in IntelliJ IDEA 2016.1.3, that I am building into jar file (Build -> build artifacts... -> build), everything works well until I wanted to use external library (org.apache.commons:commons-lang3:3.4), well no big deal, it work in IDE. But the extracted jar need that dependency. How to do that?
I have tried do Project structure -> Project Settings -> Artifacts -> and add as library.
The wanted dependecy jar is located in root folder of jar artifact, but still get this error, when try to use that code.
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
....
....
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 37 more
What have I missed?
As I mentioned in comment above, I have used my custom implementation instead of using whole library.
But in another project I have just run into same issue, this time with nanohttpd , which of course is not easy to implement myself like in previous usage :D
I have found that the order of creation of artifact/maven dependency matters Because I have first added dependency like before, but before creating config for artifact.
And voilà, dependency has been extracted and the final artifactory works well :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.