Java tutorial
//package com.java2s; public class Main { public static Class loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException { try { char start = className.charAt(0); if (start == '[') { return Class.forName(className); } if (className.equals("boolean")) { return boolean.class; } if (className.equals("byte")) { return byte.class; } if (className.equals("char")) { return char.class; } if (className.equals("short")) { return short.class; } if (className.equals("int")) { return int.class; } if (className.equals("long")) { return long.class; } if (className.equals("float")) { return float.class; } if (className.equals("double")) { return double.class; } if (className.equals("void")) { return void.class; } return Class.forName(className); } catch (ClassNotFoundException e) { return classLoader.loadClass(className); } } }