Here you can find the source of getClass(String name)
Parameter | Description |
---|---|
name | The class name, either fully qualified or just the simple name |
Parameter | Description |
---|---|
Exception | an exception |
public static Class<?> getClass(String name) throws Exception
//package com.java2s; //License from project: Creative Commons License import java.util.HashMap; import java.util.Map; public class Main { private static Map<String, Class<?>> classes = new HashMap<String, Class<?>>(); /**/*from w ww. jav a2 s. c om*/ * Returns a Java class object for the specified class name. * * @param name The class name, either fully qualified or just the simple name * @return The class, if found, otherwise throws exception * @throws Exception */ public static Class<?> getClass(String name) throws Exception { for (String clazz : classes.keySet()) { if (clazz.toLowerCase().contains(name.toLowerCase())) { return classes.get(clazz); } } throw new Exception( "Class " + name + " not found, try including the package name, for instance: net.minecraft.server._version_." + name); } }