As stated in the Javadoc for System.console(), it can return null if there is no console allocated for the JVM. In fact this is often the case. So you can't rely on it being non-null.
When running your app from Eclipse, you can configure it to allocate a console. Open the launch configuration for your app, go to the Common tab, and near the bottom you'll find a checkbox option, "Allocate console (necessary for input)."
Read full article from java - Console console = System.console(); gives null - Stack Overflow
No comments:
Post a Comment