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(final String args[]) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(300, 300);/*from  w w w  .j ava 2 s .  c o m*/
    f.setLocationRelativeTo(null);

    f.setUndecorated(true);
    f.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);

    JPanel panel = new JPanel();
    panel.setBackground(java.awt.Color.white);
    f.setContentPane(panel);

    MetalLookAndFeel.setCurrentTheme(new MyDefaultMetalTheme());
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (Exception e) {
        e.printStackTrace();
    }

    SwingUtilities.updateComponentTreeUI(f);

    f.setVisible(true);
}

From source file:GetColumnNamesFromResultSet_MySQL.java

public static void main(String[] args) {
    Connection conn = null;//from  w ww  .  j  av  a  2s. c  om
    Statement stmt = null;
    ResultSet rs = null;
    try {
        conn = getConnection();
        // prepare query
        String query = "select id, name, age from employees";
        // create a statement
        stmt = conn.createStatement();
        // execute query and return result as a ResultSet
        rs = stmt.executeQuery(query);
        // get the column names from the ResultSet
        getColumnNames(rs);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    } finally {
        // release database resources
        try {
            rs.close();
            stmt.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

From source file:TransparencyPDF.java

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

        PdfGState gs1 = new PdfGState();
        gs1.setFillOpacity(0.5f);

        cb.setGState(gs1);

        cb.setColorStroke(Color.black);
        cb.setColorFill(Color.gray);
        cb.rectangle(0, 0, 100, 200);
        cb.fill();
        cb.setLineWidth(2);
        cb.rectangle(0, 0, 200, 200);
        cb.stroke();

        PdfGState gs2 = new PdfGState();
        gs2.setFillOpacity(0.1f);

        cb.setGState(gs2);

        cb.setColorStroke(Color.black);
        cb.setColorFill(Color.gray);
        cb.rectangle(50, 50, 100, 200);
        cb.fill();
        cb.setLineWidth(2);
        cb.rectangle(50, 50, 200, 200);
        cb.stroke();

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

From source file:edu.lternet.pasta.datapackagemanager.checksum.DigestUtilsWrapper.java

/**
 * Main method to test the getSHA1Checksum() method. Pass in the full path
 * to the filename as the sole command-line argument.
 * /*from w  w w.  j a v a2  s  . com*/
 * @param args    Takes one command-line argument, the full path to the
 *                file object whose checksum is being calculated
 */
public static void main(String args[]) {
    try {
        System.out.println(getSHA1Checksum(args[0]));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:DemoResultSetOracle.java

public static void main(String[] args) {
    Connection conn = null;/*from   w w  w  .  ja v a 2 s  .c  o  m*/
    Statement stmt = null;
    ResultSet rs = null;
    try {
        conn = getConnection();
        System.out.println("conn=" + conn);
        // prepare query
        String query = "select id, name, age from employees";
        // create a statement
        stmt = conn.createStatement();
        // execute query and return result as a ResultSet
        rs = stmt.executeQuery(query);
        // extract data from the ResultSet
        while (rs.next()) {
            String id = rs.getString(1);
            String name = rs.getString(2);
            int age = rs.getInt(3);
            System.out.println("id=" + id);
            System.out.println("name=" + name);
            System.out.println("age=" + age);
            System.out.println("---------------");
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    } finally {
        // release database resources
        try {
            rs.close();
            stmt.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

From source file:es.us.isa.ideas.utilities.PopulateDatabase.java

public static void main(String[] args) {

    ApplicationContext ctx;/*  w  w  w .  j av  a2 s  . c  om*/
    EntityManagerFactory emf;
    EntityManager em;
    EntityTransaction et;

    ctx = new ClassPathXmlApplicationContext("utilities/PopulateDatabase.xml");

    emf = Persistence.createEntityManagerFactory("persistenceUnit");
    em = emf.createEntityManager();
    et = em.getTransaction();

    et.begin();
    try {
        for (Entry<String, Object> entry : ctx.getBeansWithAnnotation(Entity.class).entrySet()) {
            em.persist(entry.getValue());
            System.out.println(String.format("Persisting (%s, %s@%d)", entry.getKey(),
                    entry.getValue().getClass().getName(), entry.getValue().hashCode()));
        }
        et.commit();
    } catch (Exception oops) {
        oops.printStackTrace();
        et.rollback();
        oops.printStackTrace();
    } finally {
        if (em.isOpen())
            em.close();
        if (emf.isOpen())
            emf.close();
        ((ClassPathXmlApplicationContext) ctx).close();
    }
}

From source file:StringTaggerDemo.java

public static void main(String args[]) {
    try {//from ww  w .  j  ava 2 s  .  c o m
        System.setProperty("sen.home", "../Sen1221/senhome-ipadic");
        System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
        System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "FATAL");

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Please input Japanese sentence:");

        StringTagger tagger = StringTagger.getInstance();
        // You can also get StringTagger instance by following code:
        //
        // String confPath = System.getProperty("sen.home")
        // + System.getProperty("file.separator") + "conf/sen.xml";
        // tagger = StringTagger.getInstance(confPath);

        String s;
        while ((s = br.readLine()) != null) {
            System.out.println(s);
            Token[] token = tagger.analyze(s);
            if (token != null) {
                for (int i = 0; i < token.length; i++) {
                    System.out.println(token[i].toString() + "\t(" + token[i].getBasicString() + ")" + "\t"
                            + token[i].getPos() + "(" + token[i].start() + "," + token[i].end() + ","
                            + token[i].length() + ")\t" + token[i].getReading() + "\t"
                            + token[i].getPronunciation());
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.netsteadfast.greenstep.tools.BusinessProcessManagementDeleteTools.java

public static void main(String args[]) {
    if (args == null || args.length < 1) {
        printDetails();// w w w  . java  2 s . co  m
        System.exit(1);
    }
    boolean force = false;
    String resourceId = args[1];
    String forceStr = StringUtils.defaultString(args[0]).trim().toLowerCase();
    if ("true".equals(forceStr)) {
        force = true;
    }
    try {
        BackgroundProgramUserUtils.login();
        BusinessProcessManagementUtils.deleteDeployment(resourceId, force);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            BackgroundProgramUserUtils.logout();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    System.exit(1);
}

From source file:CounterApp.java

public static void main(String args[]) {
    if (args.length == 0) {
        System.out.println("\nServlet URL must be specified");
        return;//from  w  ww.j  av  a 2  s. co m
    }

    try {
        CounterApp app = new CounterApp(args[0]);
        for (int i = 1; i <= 5; i++) {
            int count = app.getCount();
            System.out.println("Pass " + i + " count=" + count);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}

From source file:de.phoenix.submissionpipeline.Core.java

public static void main(String[] args) {

    ObjectMapper mapper = new ObjectMapper();

    SubmissionTask task;// www.j a  v  a  2  s  .com
    try {
        task = mapper.readValue(System.in, SubmissionTask.class);
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }

    try {
        CompileTask compileTask = new CompileTask(task);
        CharSequenceCompiler<Object> compiler = compileTask.compile();

        if (task.getTests().isEmpty()) {
            writeResult(mapper, new PhoenixSubmissionResult(SubmissionStatus.COMPILED, "Everything fine!"));
            return;
        }

        JUnitTask testTask = new JUnitTask(compiler, task);
        PhoenixSubmissionResult result = testTask.run();
        writeResult(mapper, result);
    } catch (UserSubmissionException e) {
        writeResult(mapper, new PhoenixSubmissionResult(SubmissionStatus.ERROR, e.getMessage()));
    }
}