Here you can find the source of classExists(String className, Object context)
Parameter | Description |
---|---|
className | a parameter |
context | a parameter |
public static boolean classExists(String className, Object context)
//package com.java2s; public class Main { /**//w w w . j a v a 2s .co m * Checks if a certain class name exists in a certain object context's class * loader. * * @param className * @param context * @return */ public static boolean classExists(String className, Object context) { boolean canWork = false; try { canWork = Class.forName(className, false, context.getClass().getClassLoader()) != null; } //catch (ClassNotFoundException e) //{ //} catch (Exception e) { // Normally throws checked ClassNotFoundException // This also throws unckecked security exceptions } return canWork; } }