如何让 Eclipse 提示我输入命令行参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/313270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make Eclipse prompt me for command line arguments
提问by Rahul
I know I can configure command line arguments in the Run configuration but I want to run a java file multiple times with different command line arguments. It's a pain to change the Run Configuration every time.
我知道我可以在运行配置中配置命令行参数,但我想使用不同的命令行参数多次运行 java 文件。每次更改运行配置都很痛苦。
Is there a way I can make Eclipse prompt me for command line arguments every time I run the program?
有没有办法让 Eclipse 在每次运行程序时提示我输入命令行参数?
回答by Ken Gentle
Add string_prompt
as a Program Argument
in the Run
configuration.
在配置中添加string_prompt
为 a 。Program Argument
Run
${string_prompt}
There are also a file_prompt
and a folder_prompt
if you want specifically files\folders.
如果您想要特定的文件\文件夹,还有一个file_prompt
和一个folder_prompt
。
These are available through the Variables
button on the (x)= Arguments
tab of the Run Configuration dialog.
这些都可以通过Variables
该按钮(x)= Arguments
的运行配置对话框中的选项卡。
回答by Caleb
This is an old question, but since I really don't see this extra info anywhere else
这是一个老问题,但因为我真的没有在其他任何地方看到这个额外的信息
You can also type ${string_prompt:My Prompt Text:Default Value}
你也可以输入 ${string_prompt:My Prompt Text:Default Value}
And that will pop up a window asking 'Please input a value for My Prompt Text' and then with a default value of 'Default Value'.
这将弹出一个窗口,询问“请为我的提示文本输入一个值”,然后使用默认值“默认值”。
回答by bigcmos
In addition you can add a string to the prompt by using ${string_prompt:My Prompt Text} which will show the dialog box with 'Please input a value for My Prompt Text'.
此外,您可以使用 ${string_prompt:My Prompt Text} 将字符串添加到提示中,这将显示带有“请为我的提示文本输入值”的对话框。