在Java中,如何创建将使用特定类路径(可能只是一个jar文件)的ClassLoader?
您创建一个URLClassLoader
对象。
Here is a good article on class loading:
Indeed, create a URLClassLoader
as pointed out by @bmargulies. It's pretty easy to use, just pass an array of URLs into the constructor.
Maybe also check this thread and, in particular, this post for some tips on how to use Java (hierarchical) ClassLoaders. I don't know what you want to do exactly but you may find it useful.
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.