johnny-b-goode
johnny-b-goode

Reputation: 3893

How to see full exception stack trace when running java app from console?

While running java app from console i got an exception, that contains following line:

... 5 more

Is it possible to see a full trace? Is there any cmd argument?

Thanks.

Upvotes: 12

Views: 6142

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533442

The full trace is there, but it is a repeat of the nested exception above which is why it is summarised.

public class Main {
    public static void throwsException() {
        throw new UnsupportedOperationException();
    }

    public static void main(String... args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Main.class.getMethod("throwsException").invoke(null);
    }
}

prints

Exception in thread "main" java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:601)
     at Main.main(Main.java:27)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:601)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.UnsupportedOperationException
     at Main.throwsException(Main.java:23)
     ... 10 more

The ... 10 more means it is a repeat of the stack trace of the exception which wraps it.

Upvotes: 15

Related Questions