/**
* In the D:/LoadLibrary we must have .class and the same interface (TestString) with the same pacakge as the
* main program.
*/
URL urlToJar =
new URL("file://D:/LoadLibrary/");
System.
out.
println("loading...");
Class c2 = cl.loadClass("TestHelloWorld");
System.
out.
println("loaded!");
Object nouObject = c2.
newInstance();
TestString ts = (TestString) cons.newInstance(args);
/**
* Now we can use the "ts" object as a normal TestString interface. No matter which is the implementation that is begin it.
*/
System.
out.
println("S1: " + ts.
printS1());
System.
out.
println("S2: " + ts.
printS2());
0 comment about "Loading a dinamic Library"