Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java application not terminating immediatly after CTRL-C

843829Sep 23 2010 — edited Sep 24 2010
Hello

I'm running a very simple console app. When I try to stop it with CTRL-C it doesn't stop immediatly but prints a line and then dies.
This is the code:
import java.io.Console;

class TestCtrlC {
	public static void main(String[] args) {
        final Console console = System.console();
        String line;
        do {
            System.out.println("Write someting");
            line = console.readLine();
        } while (line == null);
	}
}
And this the output:

D:\>java TestCtrlC
Write something <- Here I press ctrl-c without typing anything else.
Write something

D:\>

D:\>ver
Microsoft Windows XP [Versión 5.1.2600]

D:\>java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)

Any ideas about this behaviour?

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 22 2010
Added on Sep 23 2010
10 comments
5,558 views