There used to be a bug in eclipse that prevented a run configuration from redirecting a file to stdin but supposedly it's fixed. However, I can't find any documentation that tells how to do it now that it's fixed.
It's easy to misunderstand what I'm trying to accomplish so let me be clear. I'm not looking for code that will read a file. I'm not looking to pass a filename as an arg. I'm not looking to redirect stdout or stderr.
I have existing code that takes normal standard input without knowing if it's coming from the keyboard or a file:
scanner = new Scanner(System.in);
number = scanner.nextInt();
Redirecting input from a file can be done at a command prompt of course but I'm trying to get eclipse configured to do it automatically at the touch of a ctrl-F11 keystroke.
Fair warning, I've done a number of web searches trying to answer this myself and many of them claim the answer is in Run Configuration
| Common
but they end up only working for stdout.
This is the announcement and description of the feature for Eclipse 4.5 (Mars): http://eclipse.org/mars/noteworthy/#_assigning_stdin_to_a_file
Stdin can now be assigned to a file in the Common tab of launch configuration dialogs.
As expected, this is a new feature of the just released Eclipse 4.5 and will therefore not work in an older version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With