d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Java Runtime Errors
Add Reply New Topic New Poll
Member
Posts: 7,132
Joined: Nov 1 2008
Gold: 0.00
Oct 18 2012 07:48pm
Hi,

I have not turned any project I have worked on into an actual .jar file before. Usually I simply program in the eclipse JDE, which obviously prints runtime errors into the console.

Is there any way to get access to this information when running as a .jar (as there is no environment for the compiler to print errors to)? I.e. printing errors to a file or such.

I am assuming something can be done at a function level with exceptions, but have never used exceptions before. Is it possible to somehow save the entire error log?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 18 2012 07:58pm
couple different options. my #1 recommendation is log4j. you will have to rewrite your logs.

alternatively, you can redirect System.err to point to a file. anytime you do exception.printStackTrace() it prints to System.err which will go to your file. this will be the least amount of code change i think.

you can also use another framework. i think java.util has something, but not as good as log4j.

or you can just write your own code to handle writing to files

Quote
as there is no environment for the compiler to print errors to

the compiler doesn't print runtime errors. it only prints compile time errors

This post was edited by carteblanche on Oct 18 2012 08:08pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll