This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how come i cannot use printStackTrace in a constructor? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how come i cannot use printStackTrace in a constructor?" Watch "how come i cannot use printStackTrace in a constructor?" New topic
Author

how come i cannot use printStackTrace in a constructor?

Mindy Wu
Ranch Hand

Joined: Jan 12, 2001
Posts: 121
I have a some jdbc stuff in my constructor and i want to use printStackTrace in my catch block so that i can see the error msg. However, it is not working and here is the msg i saw after compiling "'void' type not allowed here".
Can anyone explain to me how to use printStackTrace()?
Thank you!
A Agrawal
Ranch Hand

Joined: Jul 13, 2001
Posts: 41
I think you are passing printStackTrace() as a parameter to System.out.println().just check your code, if you are doing so.
Actually simple printStackTrace() is enough and you need not pass it to System.out.println() for printing it.
If you still hv this problem, plz post the code you hv written in catch block.

------------------
Amit Agrawal,
New Delhi, India.
[This message has been edited by A Agrawal (edited July 27, 2001).]


Amit Agrawal,<BR>New Delhi, India.
Sam Dalton
Author
Ranch Hand

Joined: Jul 26, 2001
Posts: 170
Use e.printStackTrace(System.out)
where e is your exception


<a href="http://www.samjdalton.com" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of [http://www.amazon.com/exec/obidos/tg/detail/-/1590592255/qid=1068633302//ref=sr_8_xs_ap_i0_xgl14/104-4904002-9274339?v=glance&s=books&n=507846]Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1861007701/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/186100561X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how come i cannot use printStackTrace in a constructor?
 
Similar Threads
NX: URLy Bird 1.3.1 Explicit Fatal Exception Handling
Data not insert.
Got this java joke in my email
How to compare AlertType
Exception Handling