Java Class Exist classExists(String className)

Here you can find the source of classExists(String className)

Description

class Exists

License

Apache License

Declaration

public static boolean classExists(String className) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static boolean classExists(String className) {
        try {//from w  w  w  .  ja v  a2s .  c o  m
            forName(className);
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    public static Class<?> forName(String name) {
        return forName(name, null);
    }

    public static Class<?> forName(String name, ClassLoader loader) {
        try {
            if (loader == null) {
                return Class.forName(name);
            }
            return Class.forName(name, true, loader);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. classExists(ClassLoader loader, String className)
  2. classExists(String className)
  3. classExists(String className)
  4. classExists(String className, Object context)
  5. classExists(String implClassName)
  6. classExists(String name)