Skip to content

Instantly share code, notes, and snippets.

@cloudhuang
Last active December 26, 2015 02:19
Show Gist options
  • Save cloudhuang/7077578 to your computer and use it in GitHub Desktop.
Save cloudhuang/7077578 to your computer and use it in GitHub Desktop.
URL class loader
URLClassLoader classLoader = null;
try {
// create url class loader to load the servlet class
URL[] urls = new URL[1];
URLStreamHandler urlStreamHandler = null;
File classPath = new File(Constents.WEB_ROOT);
String repository = (new URL("file", null, classPath.getCanonicalPath() + File.separator)).toString();
urls[0] = new URL(null, repository, urlStreamHandler);
classLoader = new URLClassLoader(urls);
} catch (Exception e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment