It will be unloaded when the ClassLoader of the Class
that loaded it is unloaded.
As has been mentioned in a few scattered places, in reality it's a bit more complex than this.
First, what matters is when the "class" which loaded the libary is unloaded, which may happen when the loader
object which created it gets garbage-collected. (Internally I believe this is actually because the loader object holds a reference to the "class", which is a Java object in its own right.) Note that the
class of the loader may remain loaded, which is actually very likely since that loader was probably loaded by the default loader object, which will probably not be garbage collected during normal execution.
Also note that unless you call System.runFinalizerOnExit(true) (which is
not recommended) you are not guaranteed that the loader will ever be finalized, so you are not guaranteed that your JNUI_onUnload routine will ever be called. If you really really need something to happen in C before shutdown, the recommendation I've seen is to add a call to a native method using Runtime.addShutdownHook().