Skip to content

Console input cursor does not reposition correctly after invalid input in Java program #2127

@abhigithb

Description

@abhigithb

Description:

When running a Java program in Eclipse IDE that uses Scanner.nextLine() for user input, the console fails to reposition the input cursor correctly after an exception or invalid input. Even though the program prints a new prompt using System.out.println("Enter a number:"), the cursor remains stuck on the previous line (next to the error message), requiring manual mouse interaction to continue typing.

NOTE: This issue does not occur in IntelliJ IDEA, where the input cursor automatically moves to the correct line after each prompt.

Steps to Reproduce:

1)Create a Java program that reads user input using Scanner.nextLine().

2)Wrap the input logic in a loop with exception handling.

3)Run the program in Eclipse IDE.

4)Enter an invalid input (e.g., non-numeric string).

5)Observe the cursor position.

Actual Behavior: The cursor stays stuck with the error message, and the user must manually click to reposition it.

Expected Behavior: The input cursor should automatically move to the next line after printing the prompt, allowing the user to type without clicking.

IDE Configuration :

Eclipse IDE for Java Developers (includes Incubating components)
Version: 2023-06 (4.28.0)
Build id: 20230608-1333

Console_cursor.mp4

BestFitTypeWithPrecision.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions