java - Load any libraries form any location after export -


is possible load additional libraries after jar has been created? want search folder jar-files, , load them libraries. "they" extend class, have, can adress them. folder, of libs not same folder, jar-file, loads others located. if there no other way, change settingsfile(where libraries-to-be-loaded linked) withinin jar itself, not great helpful, too;)

thanks

simon

yes is. have use urlclassloader.

urlclassloader loader = new urlclassloader(new url[]{new url("jar:file:/home/myapp/plugins/dateplugin.jar!/")}, classloader.getsystemclassloader()); myinterface pluginclass = (myinterface )loader.loadclass("com.mypackage.myclass").newinstance(); 

urlclassloader java doc

you want make sure connect classloader main 1 passing system classloader constructor. allow assign newly loaded library existing interface. how can make plugin system game or application.

here link source code showing in action: git hub repository sticky. @ class sticky.gui.main. shows plugin system loading new libraries after has started running.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -