List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:Main.java
public static void main(String... args) { try {// w w w.j ava2 s. c o m Class<?> c = Class.forName("Main"); Method[] allMethods = c.getDeclaredMethods(); for (Method m : allMethods) { Annotation[][] types = m.getParameterAnnotations(); } } catch (ClassNotFoundException x) { x.printStackTrace(); } }
From source file:Main.java
public static void main(String... args) { try {//from www . j a v a2 s . c o m Class<?> c = Class.forName("Main"); Method[] allMethods = c.getDeclaredMethods(); for (Method m : allMethods) { Type gpType = m.getGenericReturnType(); System.out.println(gpType); } } catch (ClassNotFoundException x) { x.printStackTrace(); } }
From source file:Main.java
public static void main(String... args) { try {/*w ww.ja va 2 s. c o m*/ Class<?> c = Class.forName("Main"); Method[] allMethods = c.getDeclaredMethods(); for (Method m : allMethods) { TypeVariable[] types = m.getTypeParameters(); for (TypeVariable t : types) { System.out.println(t); } } } catch (ClassNotFoundException x) { x.printStackTrace(); } }
From source file:Main.java
public static void main(String... args) { try {//w w w .j av a2 s .c om Class<?> c = Class.forName("Main"); Method[] allMethods = c.getDeclaredMethods(); for (Method m : allMethods) { Class<?>[] pType = m.getParameterTypes(); Type[] gpType = m.getGenericParameterTypes(); for (int i = 0; i < pType.length; i++) { out.format(fmt, "ParameterType", pType[i]); out.format(fmt, "GenericParameterType", gpType[i]); } } } catch (ClassNotFoundException x) { x.printStackTrace(); } }
From source file:Main.java
public static void main(String... args) { try {/*w w w . j a v a 2 s. co m*/ Class<?> c = Class.forName(args[0]); Class[] argTypes = new Class[] { String[].class }; Method main = c.getDeclaredMethod("main", argTypes); String[] mainArgs = Arrays.copyOfRange(args, 1, args.length); System.out.format("invoking %s.main()%n", c.getName()); main.invoke(null, (Object) mainArgs); // production code should handle these exceptions more gracefully } catch (ClassNotFoundException x) { x.printStackTrace(); } catch (NoSuchMethodException x) { x.printStackTrace(); } catch (IllegalAccessException x) { x.printStackTrace(); } catch (InvocationTargetException x) { x.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(300, 300);// w w w . j a v a 2 s.c om frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("System LAF Demo"); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } SwingUtilities.updateComponentTreeUI(frame); frame.setVisible(true); }
From source file:ChainedExceptionDemo.java
public static void main(String[] args) { String driver = "com.mysql.jdbc.Driver"; String connectionURL = "jdbc:mysql://127.0.0.1:3306/sample"; try {/* w ww . j av a2s . co m*/ Class.forName(driver); } catch (java.lang.ClassNotFoundException e) { e.printStackTrace(); } try { conn = DriverManager.getConnection(connectionURL); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM NONEXISTINGTABLE"); rs.next(); rs.close(); } catch (SQLException sx) { for (Throwable e : sx) { System.err.println("Error encountered: " + e); } } }
From source file:ConstructorTrouble.java
public static void main(String... args) { try {//from w w w.j av a2 s .c o m Class<?> c = Class.forName("ConstructorTrouble"); Object o = c.newInstance(); // InstantiationException // production code should handle these exceptions more gracefully } catch (ClassNotFoundException x) { x.printStackTrace(); } catch (InstantiationException x) { x.printStackTrace(); } catch (IllegalAccessException x) { x.printStackTrace(); } }
From source file:Eon.java
public static void main(String... args) { try {/*from w w w . ja v a2s . c o m*/ 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:FieldSpy.java
public static void main(String... args) { try {// www .j ava 2s . c o m Class<?> c = Class.forName("FieldSpy"); Field f = c.getField("name"); System.out.format("Type: %s%n", f.getType()); System.out.format("GenericType: %s%n", f.getGenericType()); // production code should handle these exceptions more gracefully } catch (ClassNotFoundException x) { x.printStackTrace(); } catch (NoSuchFieldException x) { x.printStackTrace(); } }