Is it possible to use I/O redirection in Eclipse?
I want to redirect standard input/output on the command line like java MyProgram <input.txt >output.txt, but I can’t seem to get it to work in Eclipse. I tried including the <‘s as part of the program arguments, which was ignored, and also in the VM arguments, which just threw up a class not found error. How can I do this?
To truly redirect both, the simplest way is still to define your program as an external script
(adapt the number of parameters to your particular program)
In the Run menu, click ‘External Tools…/Open External Tools Dialog” and define an external launch configuration in which you will specify both the arguments and the input and output file.
It is not an ideal solution though, as you cannot debug directly your code (with a “debug” launcher configuration).
Instead you have to remote debug it (add ‘
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000‘ in your generic Java launcher script)Once you have launched your external tool, launch a remote debug session through the “debug launcher ‘Remote Java Application'” section: