简体   繁体   中英

Make sure that all Java classes referenced inside JAR/classpath are present in the JAR/classpath

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM