I want to make sure that a JAR won't throw NoClassDefinitionFound exception before it is deployed to a server. More advanced requirement is to be able to specify additional class paths.
How this can be done?
In general it is not possible since your JAR file can load classes dynamically using Class.forName()
or ClassLoader.loadClass()
methods
I would say that the proper approach is to use some dependency management tool during your build process which will assemble all the dependencies for you.
Maven war plugin will do it for you automatically
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.