Showing posts with label classloader. Show all posts
Showing posts with label classloader. Show all posts

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 »
Labels: ,
© Zone817. Powered by Blogger.