Loading a class using the URLClassLoader

0

The URLClassLoader can be used dynamically load classes from a directory , not necessarily on the classpath. The following code demonstrates how 


File file = new File("<directory path>"); try { URL url = file.toURL(); ClassLoader loader= new URLClassLoader(new URL[]{url}); Class class= loader.loadClass("<class name>"); } catch (MalformedURLException e) { } catch (ClassNotFoundException e) { }

Read more »

0 comments:

Post a Comment

© Zone817. Powered by Blogger.