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:Test.java

public static void main(String args[]) {
    try {// w  ww. java 2s . c o  m
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD");
        System.out.println(sdf.parse(args[0]).toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] unused) {
    try {//  w  w  w.ja va 2  s .  c o m
        Class d = Class.forName("java.util.Date");
        System.out.println(d.getDeclaredAnnotations().length);

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

From source file:Main.java

public static void main(String... args) {
    Callable<UUID> callable = UUID::randomUUID;
    try {/* ww  w  . j  a v a 2  s  . co m*/
        System.out.println(callable.call());
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:Main.java

public static void main(String[] unused) {
    try {/*from w  w w .  j a  v a 2  s . c o  m*/
        String n = "java.lang.Deprecated";
        Class c = Class.forName(n);
        System.out.println(c.isAnnotation());

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

From source file:Main.java

public static void main(String[] unused) {
    try {//  ww w  .j a v a 2  s  . c o m
        String n = "java.lang.Deprecated";
        Class c = Class.forName(n);
        Class d = Class.forName("java.util.Date");
        System.out.println(d.isAnnotationPresent(c));

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

From source file:Main.java

public static void main(String[] unused) {
    try {/*from   w  ww. j  ava 2  s  .  c  om*/
        String n = "java.lang.Deprecated";
        Class c = Class.forName(n);
        Class d = Class.forName("java.util.Date");
        System.out.println(d.getAnnotation(c));

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

From source file:Main.java

public static void main(String[] args) {

    try {// w  w  w  . ja  v a  2  s . c o m
        InetAddress me = InetAddress.getLocalHost();
        String dottedQuad = me.getHostAddress();
        System.out.println("My address is " + dottedQuad);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    try {/* w  ww  .j av a2  s.c o m*/
        // create a process and execute notepad.exe
        Runtime runTime = Runtime.getRuntime();
        Process process = runTime.exec("notepad.exe");

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

}

From source file:EncryptorExamplePDF.java

public static void main(String[] args) {
    try {//  w  w  w .  j a v a 2s . c  om
        PdfReader reader = new PdfReader("YourOwnPDF.pdf");
        PdfEncryptor.encrypt(reader, new FileOutputStream("EncryptorExamplePDF.pdf"), "Hello".getBytes(),
                "World".getBytes(), PdfWriter.AllowPrinting | PdfWriter.AllowCopy, false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    try {//from  w  ww. java  2  s.com
        Class.forName(driver);
        Connection conn = DriverManager.getConnection(url, username, password);
        System.out.println(conn.getMetaData().getDatabaseProductName());
    } catch (Exception e) {
        e.printStackTrace();
    }
}