I/O redirection in Eclipse?

后端 未结 2 1314
滥情空心
滥情空心 2020-12-07 01:52

Is it possible to use I/O redirection in Eclipse?

I want to redirect standard input/output on the command line like java MyProgram output.txt

2条回答
  •  时光说笑
    2020-12-07 02:09

    To truly redirect both, the simplest way is still to define your program as an external script

     "java %1 %2 %3 %4 < %5 > %6"
    

    (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:

    Remote Debug, after blog.jmwyttenbach.net/wp-content/uploads/2007/10/eclipseremotedebug.jpg

提交回复
热议问题