Home > Java > javaTutorial > Why Does System.console() Return Null When Debugging in Eclipse?

Why Does System.console() Return Null When Debugging in Eclipse?

Susan Sarandon
Release: 2024-12-12 19:55:10
Original
663 people have browsed it

Why Does System.console() Return Null When Debugging in Eclipse?

System.console() Returns Null in Eclipse Debug Mode

When using the readLine method of BufferedReader to read input or a new password from a user, masking the password with the java.io.Console class is preferred. However, encountering a null return from System.console() while debugging in Eclipse can be frustrating.

Unfortunately, this issue is attributed to a bug (#122429) in Eclipse itself. The workaround involves disabling console logging during debugging:

  1. Navigate to the Eclipse Preferences window (Window > Preferences on Windows/macOS, Eclipse > Preferences on Linux).
  2. Expand the "Java" node and select the "Console" subcategory.
  3. Clear the "Show console only for active contents" checkbox.

This modification allows System.console() to function correctly even when debugging in Eclipse.

The above is the detailed content of Why Does System.console() Return Null When Debugging in Eclipse?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template