I am new in ClassLoader issue in Java. So how can i call methods like
getDefault().GetImage();
This is my current code:
ClassLoader tCLSLoader = new URLClassLoader(tListURL);
Class<?> tCLS = tCLSLoader.loadClass("com.github.sarxos.webcam.Webcam");
// MY FAILED TEST
Method tMethod = tCLS.getDeclaredMethod("getDefault().GetImage");
tMethod.invoke(tCLS, (Object[]) null);
EDIT:
I tried this:
Method tMethod1 = tCLS.getDeclaredMethod("getDefault");
Object tWebCam = tMethod1.invoke(tCLS, (Object[]) null);
// WebCam - Class
Class<?> tWCClass = tWebCam.getClass();
Method tMethod2 = tWCClass.getDeclaredMethod("getImage");
tMethod2.invoke(tWCClass, (Object[]) null);
But I get:
java.lang.IllegalArgumentException: object is not an instance of declaring class
I need to get this result:
BufferedImage tBuffImage = Webcam.getDefault().getImage();