title: Why doesn't the console prompt for an input?
body: <pre><code>import java.io.*;
  
  public class ConsoleDemo {
  
  public static void main(String[] args) {
      String str;
      Console con;
  
      con = System.console();
  
      if (con == null)
          return;
  
      str = con.readLine("Enter a string :    ");
      con.printf("Here is your string %s", str);
    }
  }
  </code></pre>
  
  <p>I copied this code from the book, which says that I would get a prompt on the screen for entering a string, but my IDE just gives the message that the execution has termination, without giving me a prompt.</p>