How To: Java Stack Trace in Linux

By Angsuman Chakraborty, Gaea News Network
Sunday, February 24, 2008

A simple tip for newbies - how to get Java stack trace, the invaluable tool to debug java programs, in Linux:
- Type the Ctrl key followed by \, in short Ctrl \.

I just used it to debug a persistent problem where a server process which automatically fetches data from a third-party site was inexplicably hanging.

All of us who used Ctrl-Break on windows for a stack trace, like myself will find this non-intuitive. It took me some time and googling to figure this out, so I decided to (document) blog it once and for all.

Discussion
September 5, 2008: 8:05 pm

You just need to set the classpath properly. Does you jar contain all the required class files?


baba
September 5, 2008: 9:22 am

Hi Angsuman,

I am trying to run my Jar or Linux SUSE 10, when I run it, it just gives me the following error, no trace.

How can I get the full trace. Please help.

dsadm@mach1:/opt/IBM/media/SAP/sapjco> java -jar ditest1.jar
The java class is not found: com/sap/mw/jco/JCO$Exception
dsadm@mach1:/opt/IBM/media/SAP/sapjco>

February 24, 2008: 4:35 am

Thanks for sharing.

Take care,
Angsuman

February 24, 2008: 3:50 am

hi there,

I use jps and jstack utilities in the JDK (java 1.5 and above from sun) to do the above trick.

If the java process is a daemon then, the jstack technique will work whereas you won’t be able to do the CTRL + \ trick.

just my 2 cents.

BR,
~A

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :