Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

System.console()  RSS feed

 
Jacky Stark
Ranch Hand
Posts: 44
2
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The above piece of code waits for me to enter something in the console. But the following code:-



does not wait at all throws a null pointer as soon as I run.
I am using eclipse and Intellij to simulate the same. Behavior in both the IDE's are same.
 
Andrea Binello
Ranch Hand
Posts: 47
4
Eclipse IDE Java Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jacky Stark wrote:

does not wait at all throws a null pointer as soon as I run.

In order to use java.io.Console, you must have a "real" console, one that is provided by your operating system (e.g. the Command prompt on Windows).
Not the Console "view" in Eclipse, which is not a real console.
 
Jacky Stark
Ranch Hand
Posts: 44
2
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrea, you mean to say that instead of IDE I should try to execute the code using conventional methods?...
 
Andrea Binello
Ranch Hand
Posts: 47
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jacky Stark wrote:instead of IDE I should try to execute the code using conventional methods?...

Yes, you have to open the Command prompt/Console of your OS, then change the current directory (if necessary and where appropriate), then launch java etc ... with appropriate options and arguments (here depends if you have created a single jar or distinct .class files and if -classpath option is necessary)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!