I'm trying to execute jar file from command line and still getting NoClassDefFoundError
exception but the exception message ends with "... 13 more
". Means lines I guess.
So how to get full exception message from command prompt? I'm using IntelliJ 14
as development enviroment, but debug and compilation shows no errors and ends successfully. (This is artifact build)
I was even trying to write that error message to file in try/catch
block, but my guess is that happens before the main method code executes, because no file is created or System.out.println()
is not executed.
You already have the full stack trace. The "... 13 more
" message is simple suppressing redundant/repeated information.
Let me illustrate:
public static void main(String[] args) throws Exception { a(); }
private static void a() { b(); }
private static void b() { c(); }
private static void c() { d(); }
private static void d() { try { e(); } catch (Exception e) { throw new RuntimeException(e); } }
private static void e() { f(); }
private static void f() { g(); }
private static void g() { try { h(); } catch (Exception e) { throw new IllegalStateException(e); } }
private static void h() { i(); }
private static void i() { j(); }
private static void j() { throw new UnsupportedOperationException("Test"); }
This code throws an exception deep in a call stack. The exception is caught and wrapped in other exceptions, so the output will be:
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalStateException: java.lang.UnsupportedOperationException: Test
at stackoverflow.Main.d(Main.java:11)
at stackoverflow.Main.c(Main.java:10)
at stackoverflow.Main.b(Main.java:9)
at stackoverflow.Main.a(Main.java:8)
at stackoverflow.Main.main(Main.java:6)
Caused by: java.lang.IllegalStateException: java.lang.UnsupportedOperationException: Test
at stackoverflow.Main.g(Main.java:14)
at stackoverflow.Main.f(Main.java:13)
at stackoverflow.Main.e(Main.java:12)
... 5 more
Caused by: java.lang.UnsupportedOperationException: Test
at stackoverflow.Main.j(Main.java:17)
at stackoverflow.Main.i(Main.java:16)
at stackoverflow.Main.h(Main.java:15)
... 8 more
The 5 lines suppressed for the IllegalStateException
call stack are the same as the lines from the RuntimeException
call stack.
The 8 lines suppressed for the UnsupportedOperationException
call stack are the same as the lines from the other two call stacks.
Without suppression, the output would be:
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalStateException: java.lang.UnsupportedOperationException: Test
at stackoverflow.Main.d(Main.java:11)
at stackoverflow.Main.c(Main.java:10)
at stackoverflow.Main.b(Main.java:9)
at stackoverflow.Main.a(Main.java:8)
at stackoverflow.Main.main(Main.java:6)
Caused by: java.lang.IllegalStateException: java.lang.UnsupportedOperationException: Test
at stackoverflow.Main.g(Main.java:14)
at stackoverflow.Main.f(Main.java:13)
at stackoverflow.Main.e(Main.java:12)
at stackoverflow.Main.d(Main.java:11)
at stackoverflow.Main.c(Main.java:10)
at stackoverflow.Main.b(Main.java:9)
at stackoverflow.Main.a(Main.java:8)
at stackoverflow.Main.main(Main.java:6)
Caused by: java.lang.UnsupportedOperationException: Test
at stackoverflow.Main.j(Main.java:17)
at stackoverflow.Main.i(Main.java:16)
at stackoverflow.Main.h(Main.java:15)
at stackoverflow.Main.g(Main.java:14)
at stackoverflow.Main.f(Main.java:13)
at stackoverflow.Main.e(Main.java:12)
at stackoverflow.Main.d(Main.java:11)
at stackoverflow.Main.c(Main.java:10)
at stackoverflow.Main.b(Main.java:9)
at stackoverflow.Main.a(Main.java:8)
at stackoverflow.Main.main(Main.java:6)
That is just a lot of useless redundant waste of output, and gets a lot worse in real applications where the call stacks are much deeper.