title: Java code run from a Windows CLI still gets a null System.console()
body: <p>There are a bunch of questions here and around the 'net about working with Java's System.console() in various environments.  Most of them have to do with the restrictions and caveats of getting a null return, i.e., "when no console is available".  Fair enough.</p>
  
  <p>My confusion stems from seeing a null return even when I'm working from a command-line environment on Windows.  (Note, this is <strong>NOT</strong> about doing anything from inside Eclipse; that's been asked and answered a million times already, and I'm not even using Eclipse.  Also not talking about double-clicking or right-clicking or any other kind of clicking on JAR files; there's obviously no console when you're starting from a GUI file manager.)</p>
  
  <p>So far I've tried the following combinations, all under Windows 7:</p>
  
  <ul>
  <li>default Windows\System32 "java"</li>
  <li>default Windows\System32 "javaw"</li>
  <li>Sun/Oracle's standard JavaSE JRE 7u25 "java"</li>
  <li>Sun/Oracle's standard JavaSE JRE 7u25 "javaw"</li>
  <li>Sun/Oracle's JavaSE JDK 7u25 "java"</li>
  <li>Sun/Oracle's JavaSE JDK 7u25 "javaw"</li>
  </ul>
  
  <p>also</p>
  
  <ul>
  <li>all 6 of the above under both Cygwin's mintty, and plain old CMD.EXE</li>
  </ul>
  
  <p>I thought the whole point of the java/javaw distinction was that one had a console and the other didn't, but even though I'm running all 12 attempts from a command-line prompt, System.console() is always null.</p>
  
  <p>The testbed code is simple enough, and does the expected thing under other OSes (e.g., Linux, where System.console() is always there from an xterm and whatnot, but becomes null when stdin is redirected from /dev/null).</p>
  
  <p>What virgin goat do we have to sacrifice to the dark gods of Java to get a System.console() in Windows when the user is running from a CLI?</p>