JDK-8179511 : Need ability to specify a different file.encoding for stdin, stdout, and stderr
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 8,9
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2017-04-30
  • Updated: 2017-05-02
Description
A DESCRIPTION OF THE REQUEST :
On Windows, when "-Dfile.encoding" is used on the command line when running Java and I/O is either connected to pipes or redirected to files, the specified encoding will be used for stdin, stdout, and stderr, but also as the default for files that the program reads or writes. It would be nice if the I/O (stdin,stdout,stderr) encoding could be set separately.

"iofile.encoding" could be used for this purpose. If used alone, the default file encoding for other things would be unchanged. "file.encoding" used alone could behave as it does now. With both specified, "iofile.encoding" would take precedence for I/O.

JUSTIFICATION :
IDEs typically connect to a running program using pipes on Windows. For Java, it is desirable that an IDE would use UTF-8 or another Unicode-capable encoding to allow Unicode I/O to a running program or a program that is being debugged, while at the same time leaving the default encoding for the user unchanged. Currently this is not possible.

On other OS this is not a problem, as IDEs will typically connect to a running program using pseudoterminals.