does Class Exist : ClassLoader « Reflection « Java
- Java
- Reflection
- ClassLoader
does Class Exist
public class Main {
public static boolean doesClassExist(String name) {
try {
Class c = Class.forName(name);
if (c != null)
return true;
} catch (ClassNotFoundException e) {
// Class not found
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
Related examples in the same category