Example usage for java.lang Exception printStackTrace

List of usage examples for java.lang Exception printStackTrace

Introduction

In this page you can find the example usage for java.lang Exception printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public static void main(String[] args) throws AWTException {
    Runnable r = new Runnable() {
        @Override//from ww w.  jav a 2 s  . c o  m
        public void run() {
            try {
                URL url = new URL("http://www.java2s.com/style/download.png");
                BufferedImage bi = ImageIO.read(url);
                JPanel gui = new JPanel(new GridLayout(1, 2, 2, 2));

                gui.add(new JLabel(new ImageIcon(bi)));
                gui.add(new JLabel(new ImageIcon(getFlippedImage(bi))));

                JOptionPane.showMessageDialog(null, gui);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
    SwingUtilities.invokeLater(r);
}

From source file:CountRows_Oracle.java

public static void main(String[] args) {
    Connection conn = null;/*from w  ww.jav  a  2 s  .  c  om*/
    try {
        conn = getConnection();
        String tableName = "myTable";
        System.out.println("tableName=" + tableName);
        System.out.println("conn=" + conn);
        System.out.println("rowCount=" + countRows(conn, tableName));
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    } finally {
        // release database resources
        try {
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

From source file:MainClass.java

public static void main(String[] args) throws IOException {
    SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    ServerSocket ss = ssf.createServerSocket(8080);

    while (true) {
        try {/*  ww w . j a  va  2 s . c  o m*/
            Socket s = ss.accept();
            OutputStream out = s.getOutputStream();
            BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));

            String line = null;
            while (((line = in.readLine()) != null) && (!("".equals(line)))) {
                System.out.println(line);
            }
            StringBuffer buffer = new StringBuffer();
            buffer.append("<HTML><HEAD><TITLE>HTTPS Server</TITLE></HEAD>\n");
            buffer.append("<BODY>\n<H1>Success!</H1></BODY></HTML>\n");

            String string = buffer.toString();
            byte[] data = string.getBytes();
            out.write("HTTP/1.0 200 OK\n".getBytes());
            out.write(new String("Content-Length: " + data.length + "\n").getBytes());
            out.write("Content-Type: text/html\n\n".getBytes());
            out.write(data);
            out.flush();

            out.close();
            in.close();
            s.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:TestDebug_MySQL.java

public static void main(String[] args) {
    Connection conn = null;//from   w  w w .j a  v  a 2s  .c om
    try {
        PrintWriter pw = new PrintWriter(new FileOutputStream("mysql_debug.txt"));
        DriverManager.setLogWriter(pw);
        conn = getConnection();
        String tableName = "myTable";
        System.out.println("tableName=" + tableName);
        System.out.println("conn=" + conn);
        System.out.println("rowCount=" + countRows(conn, tableName));
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    } finally {
        try {
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

From source file:basic.AcknowledgeExample.java

/**
 * @param args//  ww  w  .ja va2  s.  com
 */
public static void main(String[] args) {
    try {
        new AcknowledgeExample();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Barcode128Demo.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from w  w w. ja  v a2 s .  c om
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Barcode128.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();

        String code402 = "123456789012345" + Barcode128.FNC1;
        String code90 = "www.java2s.com" + Barcode128.FNC1;
        String code421 = "123456";
        String data = code402 + code90 + code421;

        Barcode128 shipBarCode = new Barcode128();
        shipBarCode.setX(0.75f);
        shipBarCode.setN(1.5f);
        shipBarCode.setChecksumText(true);
        shipBarCode.setGenerateChecksum(true);
        shipBarCode.setSize(10f);
        shipBarCode.setTextAlignment(Element.ALIGN_CENTER);
        shipBarCode.setBaseline(10f);
        shipBarCode.setCode(data);
        shipBarCode.setBarHeight(50f);

        Image imgShipBarCode = shipBarCode.createImageWithBarcode(cb, Color.black, Color.blue);

        document.add(imgShipBarCode);
    } catch (Exception e) {
        e.printStackTrace();
    }
    document.close();
}

From source file:Main.java

public static void main(String args[]) {
    try {//from   w  w  w. j  a v a  2  s. c  om
        DefaultBoundedRangeModel model = new DefaultBoundedRangeModel();
        ChangeListener myListener = new MyChangeListener();
        model.addChangeListener(myListener);

        System.out.println(model.toString());
        System.out.println("Now setting minimum to 50 . . .");
        model.setMinimum(50);
        System.out.println(model.toString());
        System.out.println("Now setting maximum to 40 . . .");
        model.setMaximum(40);
        System.out.println(model.toString());
        System.out.println("Now setting maximum to 50 . . .");
        model.setMaximum(50);
        System.out.println(model.toString());
        System.out.println("Now setting extent to 30 . . .");
        model.setExtent(30);
        System.out.println(model.toString());

        System.out.println("Now setting several properties . . .");
        if (!model.getValueIsAdjusting()) {
            model.setValueIsAdjusting(true);
            System.out.println(model.toString());
            model.setMinimum(0);
            model.setMaximum(100);
            model.setExtent(20);
            model.setValueIsAdjusting(false);
        }
        System.out.println(model.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:GuitarManufacturerList.java

public static void main(String[] args) {
    try {/*ww  w.j  a  v  a2 s.  c  om*/
        CustomObjectTester tester = new CustomObjectTester();

        tester.testListExtension(System.out);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ChangingCellWidthsPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 36, 36, 36, 36);
    try {/*ww w . j av a2 s . c  o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ChangingCellWidthsPDF.pdf"));
        document.open();

        float[] widths = { 0.1f, 0.1f, 0.05f, 0.75f };
        PdfPTable table = new PdfPTable(widths);
        table.addCell("10%");
        table.addCell("10%");
        table.addCell("5%");
        table.addCell("75%");
        table.addCell("111111111111111111111111111");
        table.addCell("111111111111111");
        table.addCell("11111");
        table.addCell("11");
        document.add(table);

        widths[0] = 40f;
        widths[1] = 40f;
        widths[2] = 10f;
        widths[3] = 10f;
        table.setWidths(widths);

        table.addCell("111111111111111111111111111");
        table.addCell("111111111111111");
        table.addCell("11111");
        table.addCell("11");

        document.add(table);
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:test.node.TestNodeWorker.java

public static void main(String[] args) {

    try {//  w  w  w  .ja v a  2  s.  c om

        log.info("GridNode Starting...");
        StopWatch sw = new StopWatch();
        sw.start();

        // Start Grid Node
        GridNode node = Grid.startGridNode();

        sw.stop();
        log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]");

        log.info("GridNode ID : " + node.getId());

        log.debug("Press any key to unregister GridNode and terminate");
        System.in.read();
        node.getNodeRegistrationService().unregister();

        log.info("Unregistered, Terminating...");
        System.exit(0);
    } catch (Exception e) {
        e.printStackTrace();
    }

}