I'm upgrading an app that registers the time employees arrive and leave the office. I would like not to install this app into one of our current servers, which are somewhat important, beacuse I would have to leave a session open and i'd like to keep things separated. So all I have is cheap, cheap hardware. Basically a 500MHz, 64MB RAM Debian Lenny with nothing but the app, and MySQL database to store the information, oh yes, and i'ts inside a stove.
Currently the app is written in Java. Just a console program with a Dilbert's face ascii art on it asking for the employee's ID. The actual line, that does the 'waiting' is :
id = cin.nextInt();
When the first employee arrives monday morning and types he's id, about 40 hours of no usage since last employee left, the app crashes. Cant remember the actual exception thrown.
So my question is: Is there a nice way to loop a Java app forever ? Or maybe a better question is, which programming language is better for this task ?
I guess it would seem obvious at first not to use big 'ol java on such poor system, but lets just say, I kinda like Java.
Edit: Thanks for all your replies. However I do all the try/catching there is. I'm the problem is an Error the app can not recover from such as OutOfMemoryError.
The actual code looks something like :
static boolean start() {
Scanner cin = new Scanner(System.in);
int id;
try{
id = cin.nextInt();
doStuff( id );
return true;
}catch (Exception e){
//which would trap all recoverable exceptions
System.out.println("Something is wrong. Try again.");
return false;
}
}
public static void main(String ... args){
boolean first = true;
while(true) {
if(first) showDilbert();
first = start();
}
}
I'm sorry I did not pay more attention to the actual exception, but I thought Java would be discarded quite faster from the hardware description.