prova ad aggiungere, intanto, un blocco try/catch del tipo

try {
System.in.read();
}
catch (Exception e) {}
Alla fine del main.