List of usage examples for java.lang Class getName
public String getName()
From source file:Main.java
public static void main(String[] args) throws Exception { Class cls = Class.forName("java.lang.Integer"); // returns the name and package of the class System.out.println("Class = " + cls.getName()); System.out.println("Package = " + cls.getPackage()); }
From source file:LoadDriver.java
public static void main(String[] av) { try {//from w ww.j av a 2 s . c om // Try to load the jdbc-odbc bridge driver // Should be present on Sun JDK implementations. Class c = Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("Loaded " + c.getName()); // Try to load an Oracle driver. Class d = Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println("Loaded " + d.getName()); } catch (ClassNotFoundException ex) { System.err.println(ex); } }
From source file:Class1.java
public static void main(String args[]) { Class1 x = new Class1(); Class2 y = new Class2(); Class clObj; clObj = x.getClass(); // get Class reference System.out.println("x is object of type: " + clObj.getName()); clObj = y.getClass(); // get Class reference System.out.println("y is object of type: " + clObj.getName()); clObj = clObj.getSuperclass();/*from w w w . j a v a 2 s. co m*/ System.out.println("y's superclass is " + clObj.getName()); }
From source file:Main.java
public static void main(String[] args) { String[] arr = new String[] { "java2s.com" }; // returns the Class representing the component type Class arrClass = arr.getClass(); Class componentType = arrClass.getComponentType(); if (componentType != null) { System.out.println("ComponentType = " + componentType.getName()); } else {// www. j av a 2s. c o m System.out.println("ComponentType is null"); } }
From source file:Main.java
public static void main(String[] args) throws Exception { // returns the Class object for the class with the specified name Class cls = Class.forName("java.lang.ClassLoader"); // returns the name and package of the class System.out.println("Class found = " + cls.getName()); System.out.println("Package = " + cls.getPackage()); }
From source file:name.ikysil.beanpathdsl.sandbox.describe.Main.java
/** * @param args the command line arguments *//* ww w . j a v a 2 s. c om*/ public static void main(String[] args) { PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean(); Reflections reflections = new Reflections(TestBean.class, new SubTypesScanner(false)); Set<Class<?>> classes = reflections.getSubTypesOf(Object.class); for (Class<?> clazz : classes) { System.out.println(String.format("Class name: %s", clazz.getName())); System.out.println(String.format("Class simple name: %s", clazz.getSimpleName())); System.out.println(String.format("Class canonical name: %s", clazz.getCanonicalName())); PropertyDescriptor[] pds = propertyUtilsBean.getPropertyDescriptors(clazz); for (PropertyDescriptor pd : pds) { System.out.println(String.format(" Property name: %s", pd.getName())); Class<?> pc = pd.getPropertyType(); System.out.println(String.format(" Class name: %s", pc.getName())); System.out.println(String.format(" Class simple name: %s", pc.getSimpleName())); System.out.println(String.format(" Class canonical name: %s", pc.getCanonicalName())); } } }
From source file:MyClass.java
public static void main(String[] args) { Class<MyClass> c = MyClass.class; System.out.println("Constructors for " + c.getName()); Constructor[] constructors = c.getConstructors(); ArrayList<String> constructDescList = getConstructorsDesciption(constructors); for (String desc : constructDescList) { System.out.println(desc); }/*from w w w .ja v a 2 s . co m*/ }
From source file:Eon.java
public static void main(String... args) { try {/*from w ww . j a v a 2 s .com*/ Class<?> c = (args.length == 0 ? Eon.class : Class.forName(args[0])); out.format("Enum name: %s%nEnum constants: %s%n", c.getName(), Arrays.asList(c.getEnumConstants())); if (c == Eon.class) out.format(" Eon.values(): %s%n", Arrays.asList(Eon.values())); // production code should handle this exception more gracefully } catch (ClassNotFoundException x) { x.printStackTrace(); } }
From source file:org.anarres.dblx.core.Main.java
public static void main(String[] args) throws Exception { Stopwatch stopwatch = Stopwatch.createStarted(); Arguments arguments = new Arguments(args); GenericApplicationContext context = new GenericApplicationContext(); AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(context); reader.register(AppConfiguration.class); for (AppConfiguration.Provider configurationProvider : ServiceLoader .load(AppConfiguration.Provider.class)) { for (Class<?> configurationClass : configurationProvider.getConfigurationClasses()) { LOG.debug("Registering additional ServerConfiguration class " + configurationClass.getName()); reader.register(configurationClass); }/* ww w . java 2s .c o m*/ } SpringUtils.addConfigurations(context, arguments); context.refresh(); context.registerShutdownHook(); context.start(); LOG.info("Ready; startup took " + stopwatch); }
From source file:Main.java
public static void main(String[] args) throws Exception { Class cls = Class.forName("Main"); ClassLoader cLoader = cls.getClassLoader(); Class cls2 = Class.forName("java.lang.Thread", true, cLoader); System.out.println("Class = " + cls.getName()); System.out.println("Class = " + cls2.getName()); }