title: Java: How to get input from System.console()
body: <p>I am trying to use Console class to get input from user but a null object is returned when I call <code>System.console()</code>. Do I have to change anything before using System.console?</p>
  
  <pre><code>Console co=System.console();
  System.out.println(co);
  try{
      String s=co.readLine();
  }
  </code></pre>