Here you can find the source of classForName(String cname)
Parameter | Description |
---|---|
cname | class name |
public static Class classForName(String cname)
//package com.java2s; //License from project: LGPL public class Main { /**//w ww . jav a2 s . co m * Returns the class with the given name, or null if it's not on the * path. * * @param cname class name * @return class or null */ public static Class classForName(String cname) { // Hmm - not sure now why I wanted to make sure I got this classloader. // I wonder if there is a good reason?? ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { return Class.forName(cname, true, loader); } catch (ClassNotFoundException e) { return null; } } }