java - How to load new jar files dynamically to JavaVM -
I already have a JavaVM C object which is given by my library, but I have more jar and java files Need to add that in my application
What can I do?
The library uses JNI_CreateJavaVM (and jvm, (void **) and P_JNIND, & amp; RGS); Function to create JavaVM first time need to add more options to my application.
Someone has told me that the Java object has a function to load the Java object for the already created Java object.
If I understand your question ...
Adding a Java object dynamically in a running JVM, a function is? Then use the following to dynamically add Jars to you application. (Add error check and exception handling as needed).
Zero addJarToClassPath (last file jarfile) without public synchronization {end string; filename = "addURL"; Last class & lt ;? & Gt; [] Method type = New class [] {URL.class}; Try the {final method method = URLClassLoader.class.getDeclaredMethod (methodName, methodTypes); method.setAccessible (true); Method.invoke (URLClassLoader) ClassLoader.getSystemClassLoader (), New Object [] {jarFile.toURI () .toURL ()}); } Hold (last exception e) {new runtime expansion ("failed to load" + jarFile.getAbsolutePath (), e); }}
Comments
Post a Comment