Here you can find the source of loadClassByName(String className)
Parameter | Description |
---|---|
className | Canonical class name |
Parameter | Description |
---|---|
ClassNotFoundException | an exception |
public static Class<?> loadClassByName(String className) throws ClassNotFoundException
//package com.java2s; //License from project: Apache License public class Main { /**/*ww w.j ava 2s . c o m*/ * Load Class by class name. If class not found in it's Class loader or one of the parent class loaders - delegate to the Thread's ContextClassLoader * * @param className Canonical class name * @return Class definition of className * @throws ClassNotFoundException */ public static Class<?> loadClassByName(String className) throws ClassNotFoundException { try { return Class.forName(className); } catch (ClassNotFoundException e) { return Thread.currentThread().getContextClassLoader().loadClass(className); } } }