List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:PlotDriver.java
/** Construct a Plotter driver, and try it out. */ public static void main(String[] argv) { Plotter r;//w w w. j av a2s . c om // if (argv.length != 1) { // System.err.println("Usage: PlotDriver driverclass"); // return; // } try { Class c = Class.forName("PlotterAWT"); Object o = c.newInstance(); if (!(o instanceof Plotter)) throw new ClassNotFoundException("Not instanceof Plotter"); r = (Plotter) o; } catch (ClassNotFoundException e) { System.err.println("Sorry, " + argv[0] + " not a plotter class"); return; } catch (Exception e) { e.printStackTrace(); return; } r.penDown(); r.penColor(1); r.moveTo(200, 200); r.penColor(2); r.drawBox(123, 200); r.rmoveTo(10, 20); r.penColor(3); r.drawBox(123, 200); r.penUp(); r.moveTo(300, 100); r.penDown(); r.setFont("Helvetica", 14); r.drawString("Hello World"); r.penColor(4); r.drawBox(10, 10); }
From source file:edu.wustl.xipHost.hostControl.HostConfigurator.java
public static void main(String[] args) { try {/*from ww w . jav a 2 s. c o m*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (InstantiationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalAccessException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //Turn off commons loggin for better performance System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog"); DOMConfigurator.configure("log4j.xml"); hostConfigurator = new HostConfigurator(); boolean startupOK = hostConfigurator.runHostStartupSequence(); if (startupOK == false) { logger.fatal("XIPHost startup error. System exits."); System.exit(0); } /*final long MEGABYTE = 1024L * 1024L; System.out.println("Total heap size: " + (Runtime.getRuntime().maxMemory())/MEGABYTE); System.out.println("Used heap size: " + (Runtime.getRuntime().totalMemory())/MEGABYTE); System.out.println("Free heap size: " + (Runtime.getRuntime().freeMemory())/MEGABYTE);*/ }
From source file:AutoGenKeys.java
public static void main(String args[]) { String url = "jdbc:mySubprotocol:myDataSource"; Connection con = null;// w w w .j a va2s .c o m PreparedStatement pstmt; String insert = "INSERT INTO COFFEES VALUES ('HYPER_BLEND', " + "101, 10.99, 0, 0)"; String update = "UPDATE COFFEES SET PRICE = ? WHERE KEY = ?"; try { Class.forName("myDriver.ClassName"); } catch (java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, "myLogin", "myPassword"); pstmt = con.prepareStatement(insert, Statement.RETURN_GENERATED_KEYS); pstmt.executeUpdate(); ResultSet keys = pstmt.getGeneratedKeys(); int count = 0; keys.next(); int key = keys.getInt(1); pstmt = con.prepareStatement(update); pstmt.setFloat(1, 11.99f); pstmt.setInt(2, key); pstmt.executeUpdate(); keys.close(); pstmt.close(); con.close(); } catch (SQLException e) { e.printStackTrace(); } }
From source file:GetParamMetaData.java
public static void main(String args[]) { String url = "jdbc:mySubprotocol:myDataSource"; Connection con;//from www. j av a 2s .co m PreparedStatement pstmt; ParameterMetaData pmd; String sql = "UPDATE COFFEES SET SALES = ? " + "WHERE COF_NAME = ?"; try { Class.forName("myDriver.ClassName"); } catch (java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, "myLogin", "myPassword"); pstmt = con.prepareStatement(sql); pmd = pstmt.getParameterMetaData(); int totalDigits = pmd.getPrecision(1); int digitsAfterDecimal = pmd.getScale(1); boolean b = pmd.isSigned(1); System.out.println("The first parameter "); System.out.println(" has precision " + totalDigits); System.out.println(" has scale " + digitsAfterDecimal); System.out.println(" may be a signed number " + b); int count = pmd.getParameterCount(); System.out.println("count is " + count); for (int i = 1; i <= count; i++) { int type = pmd.getParameterType(i); String typeName = pmd.getParameterTypeName(i); System.out.println("Parameter " + i + ":"); System.out.println(" type is " + type); System.out.println(" type name is " + typeName); } pstmt.close(); con.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:SetSavepoint.java
public static void main(String args[]) { String url = "jdbc:mySubprotocol:myDataSource"; try {/*w ww. ja v a 2 s.c o m*/ Class.forName("myDriver.className"); } catch (java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { Connection con = DriverManager.getConnection(url, "myLogin", "myPassword"); con.setAutoCommit(false); String query = "SELECT COF_NAME, PRICE FROM COFFEES " + "WHERE TOTAL > ?"; String update = "UPDATE COFFEES SET PRICE = ? " + "WHERE COF_NAME = ?"; PreparedStatement getPrice = con.prepareStatement(query); PreparedStatement updatePrice = con.prepareStatement(update); getPrice.setInt(1, 7000); ResultSet rs = getPrice.executeQuery(); Savepoint save1 = con.setSavepoint(); while (rs.next()) { String cof = rs.getString("COF_NAME"); float oldPrice = rs.getFloat("PRICE"); float newPrice = oldPrice + (oldPrice * .05f); updatePrice.setFloat(1, newPrice); updatePrice.setString(2, cof); updatePrice.executeUpdate(); System.out.println("New price of " + cof + " is " + newPrice); if (newPrice > 11.99) { con.rollback(save1); } } getPrice = con.prepareStatement(query); updatePrice = con.prepareStatement(update); getPrice.setInt(1, 8000); rs = getPrice.executeQuery(); System.out.println(); Savepoint save2 = con.setSavepoint(); while (rs.next()) { String cof = rs.getString("COF_NAME"); float oldPrice = rs.getFloat("PRICE"); float newPrice = oldPrice + (oldPrice * .05f); updatePrice.setFloat(1, newPrice); updatePrice.setString(2, cof); updatePrice.executeUpdate(); System.out.println("New price of " + cof + " is " + newPrice); if (newPrice > 11.99) { con.rollback(save2); } } con.commit(); Statement stmt = con.createStatement(); rs = stmt.executeQuery("SELECT COF_NAME, " + "PRICE FROM COFFEES"); System.out.println(); while (rs.next()) { String name = rs.getString("COF_NAME"); float price = rs.getFloat("PRICE"); System.out.println("Current price of " + name + " is " + price); } con.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.pianobakery.complsa.MainGui.java
public static void main(String[] args) { // take the menu bar off the jframe System.setProperty("apple.laf.useScreenMenuBar", "true"); // set the name of the application menu item //System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Semantic Analysis"); // set the look and feel try {//from w w w . jav a 2 s .c om UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } //StartUI frame = new JFrame("MainGui"); maingui = new MainGui(); frame.setContentPane(maingui.mainPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setTitle("Semantic Search"); int frameWidth = 1280; int frameHeight = 800; frame.setMinimumSize(new Dimension(frameWidth, frameHeight)); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setBounds((int) screenSize.getWidth() / 2 - frameWidth / 2, (int) screenSize.getHeight() / 4 - frameHeight / 4, frameWidth, frameHeight); JMenuBar menu = MenuExp(); frame.setJMenuBar(menu); //Sets Button as always selected //JRootPane rootPane = SwingUtilities.getRootPane(maingui.searchButton); //rootPane.setDefaultButton(maingui.searchButton); frame.setVisible(true); }
From source file:Main.java
public static Class getEventActivity() { try {// w w w.j a v a2s .c o m return Class.forName("com.imsiper.community.main.Ui.EventActivity"); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Class<?> forName(String className) { try {//from w ww . java 2 s . c o m return Class.forName(className); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Class getBoxBlendActivity() { try {//from ww w .j a v a 2s . co m return Class.forName("com.photostars.xblend.activity.BoxBlendActivity"); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Class getCommunityMainActivity() { try {/*from ww w .j av a2 s . co m*/ return Class.forName("com.imsiper.community.main.Ui.MainActivity"); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }