Here you can find the source of newInstance(String className)
public static Object newInstance(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException
//package com.java2s; public class Main { public static Object newInstance(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException { Object object = null;//ww w. j a va 2 s . c o m try { object = (Object) Class.forName(className).newInstance(); } catch (ClassNotFoundException e) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); object = (Object) cl.loadClass(className).newInstance(); } return object; } }