java - How should I load Jars dynamically at runtime? -


why hard in java? if want have kind of module system need able load jars dynamically. i'm told there's way of doing writing own classloader, that's lot of work should (in mind @ least) easy calling method jar file argument.

any suggestions simple code this?

the reason it's hard security. classloaders meant immutable; shouldn't able willy-nilly add classes @ runtime. i'm surprised works system classloader. here's how making own child classloader:

urlclassloader child = new urlclassloader (myjar.tourl(), this.getclass().getclassloader()); class classtoload = class.forname ("com.myclass", true, child); method method = classtoload.getdeclaredmethod ("mymethod"); object instance = classtoload.newinstance (); object result = method.invoke (instance); 

painful, there is.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -