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) {
    try {// w  w  w .  ja  v  a2  s .  c o  m
        // create a new process
        Process p = Runtime.getRuntime().exec("notepad.exe");

        p.destroy();

        System.out.println(p.exitValue());

    } catch (Exception ex) {
        ex.printStackTrace();
    }

}

From source file:MainClass.java

public static void main(String args[]) {

    try {//from w ww . j  a v  a2s . com

        File file = new File("c:\\winnt");
        System.out.println("getCanonicalPath() = " + file.getCanonicalPath());

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

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

        model.removeChangeListener(myListener);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String args[]) {
    try {//  ww w  . ja  v a  2s.co m
        DefaultBoundedRangeModel model = new DefaultBoundedRangeModel();
        ChangeListener myListener = new MyChangeListener();
        model.addChangeListener(myListener);
        ChangeListener[] lis = model.getChangeListeners();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:MainClass.java

public static void main(String[] unused) {
    try {/*from  w  w  w  .j  a v a2 s. c  o m*/
        String n = "java.util.List";
        Class c = Class.forName(n);

        if (c.isInterface()) {
            System.out.println(n + " is an interface");
        } else {
            System.out.println(n + " is not an interface");
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    try {//  w w  w  .j  a  v  a2s  .  co m
        // create a new process
        Process p = Runtime.getRuntime().exec("notepad.exe");

        // cause this process to stop until process p is terminated
        p.waitFor();

        // when you manually close notepad.exe this program will continue
        System.out.println("Waiting over.");

    } catch (Exception ex) {
        ex.printStackTrace();
    }

}

From source file:EncapsulatedPostScript.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {//from   www  . j a  va  2  s. com
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("EncapsulatedPostScript.pdf"));
        document.open();
        Image img = Image.getInstance("yourpsFile.ps");
        img.scalePercent(50);
        document.add(img);
        document.close();
    } catch (Exception de) {
        de.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    try {//from w w w  . jav a  2  s .  c  o m

        String[] envArray = new String[2];
        envArray[0] = "";
        envArray[1] = "";
        // create a process and execute notepad.exe and currect environment
        Runtime runTime = Runtime.getRuntime();

        Process process = runTime.exec("notepad.exe", envArray);

    } catch (Exception ex) {
        ex.printStackTrace();
    }

}

From source file:JavaScriptActionPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from  w  ww .  j av a2 s  . c  o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("JavaScriptActionPDF.pdf"));
        document.open();
        Paragraph p = new Paragraph(
                new Chunk("Click to say Hi").setAction(PdfAction.javaScript("app.alert('Hi');\r", writer)));
        document.add(p);
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String url = "jdbc:odbc:yourDBName";
    System.out.println("Attempting to connect to " + url);

    try {/*from   w  w  w  .j a  v a2 s .  co  m*/
        System.out.println("Loading the driver...");
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        System.out.println("Establishing a connection...");
        Connection connection = DriverManager.getConnection(url);

        System.out.println("Connect to " + connection.getCatalog() + " a success!");
    } catch (Exception e) {
        e.printStackTrace();
    }
}