To download the dll you need to use a separate ClassLoader . The DLL is bound only to the ClassLoader loader. When ClassLoader is no longer in use (meaning there are no links to ClassLoader), the garbage collector will free your ClassLoader and unload your DLL.
source
share