Example usage for java.lang Class forName

List of usage examples for java.lang Class forName

Introduction

In this page you can find the example usage for java.lang Class forName.

Prototype

@CallerSensitive
public static Class<?> forName(String className) throws ClassNotFoundException 

Source Link

Document

Returns the Class object associated with the class or interface with the given string name.

Usage

From source file:Main.java

public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {
        int searchMod = Modifier.STATIC;
        int mods = accessModifiers(ctor.getModifiers());
        if (searchMod == mods) {
            System.out.println(ctor);
        }// www . ja v a 2 s .  com
    }
}

From source file:Main.java

public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {
        int searchMod = Modifier.ABSTRACT;
        int mods = accessModifiers(ctor.getModifiers());
        if (searchMod == mods) {
            System.out.println(ctor);
        }//from ww  w . j  ava 2  s  .  com
    }
}

From source file:Main.java

public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {
        int searchMod = Modifier.NATIVE;
        int mods = accessModifiers(ctor.getModifiers());
        if (searchMod == mods) {
            System.out.println(ctor);
        }/*from  w w  w  .  j  a  va 2s.  c o m*/
    }
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};"
            + "Dbq=C:\\Users\\Public\\uls\\ulsTest.mdb;" + "SystemDB=C:\\Users\\Public\\uls\\Security.mdw;"
            + "Uid=Gord;" + "Pwd=obfuscated;" + "ExtendedAnsiSQL=1;");
    Statement s = conn.createStatement();
    s.execute("CREATE USER Tim pwd");
    System.out.println("User 'Tim' created.");
    s.execute("DROP USER Tim");
    System.out.println("User 'Tim' dropped.");
    s.close();//from  w w  w.  j  a  v a2  s.c  om
    conn.close();
}

From source file:MainClass.java

public static void main(String[] args) {
    try {//from   ww w . ja  v  a  2 s. co m
        String className = "oracle.jdbc.driver.OracleDriver";
        Class driverObject = Class.forName(className);
        System.out.println("driverObject=" + driverObject);
        System.out.println("your installation of JDBC Driver OK.");
    }

    catch (Exception e) {
        System.out.println("Failed: JDBC Driver Error: " + e.getMessage());
    }
}

From source file:Main.java

public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {
        int searchMod = Modifier.PROTECTED;
        int mods = accessModifiers(ctor.getModifiers());
        if (searchMod == mods) {
            System.out.println(ctor);
        }/*from   w  ww . jav  a2s  .co m*/
    }
}

From source file:Main.java

public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {
        int searchMod = Modifier.PUBLIC;
        int mods = accessModifiers(ctor.getModifiers());
        if (searchMod == mods) {
            System.out.println(ctor);
        }//  w ww. ja v  a2  s.  c  om
    }
}

From source file:Main.java

public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {
        int searchMod = Modifier.TRANSIENT;
        int mods = accessModifiers(ctor.getModifiers());
        if (searchMod == mods) {
            System.out.println(ctor);
        }/*  ww w . j  a v a  2s.c om*/
    }
}

From source file:Main.java

public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {
        int searchMod = Modifier.SYNCHRONIZED;
        int mods = accessModifiers(ctor.getModifiers());
        if (searchMod == mods) {
            System.out.println(ctor);
        }//from  w ww  .ja va  2 s. c om
    }
}

From source file:Main.java

public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {
        int searchMod = Modifier.FINAL;
        int mods = accessModifiers(ctor.getModifiers());
        if (searchMod == mods) {
            System.out.println(ctor);
        }/*w  ww  .j av a  2 s.  co m*/
    }
}