Eclipse中的I / O重定向? [英] I/O redirection in Eclipse?

查看:163
本文介绍了Eclipse中的I / O重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在Eclipse中使用I / O重定向吗?

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

我想在命令行上重定向标准输入/输出,如 java MyProgram< input.txt> output.txt ,但我似乎无法让它在Eclipse中工作。我尝试将<'作为程序参数的一部分,这被忽略,并且在VM参数中,它只是抛出一个未找到的类错误。如何做到这一点?

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

 "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.

这不是一个理想的解决方案,因为您无法直接调试您的代码(使用调试启动器配置)。

相反,您必须远程调试(在您的通用Java启动器中添加' -Xdebug -Xrunjdwp:transport = dt_socket,server = y,suspend = n,address = 8000 '脚本)

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)

启动外部工具后,通过调试启动器Remote J启动远程调试会话ava应用程序部分:

Once you have launched your external tool, launch a remote debug session through the "debug launcher 'Remote Java Application'" section:

这篇关于Eclipse中的I / O重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆