如何让 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:31:39  来源:igfitidea点击:

How to make Eclipse prompt me for command line arguments

eclipse

提问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_promptas a Program Argumentin the Runconfiguration.

在配置中添加string_prompt为 a 。Program ArgumentRun

 ${string_prompt}

There are also a file_promptand a folder_promptif you want specifically files\folders.

如果您想要特定的文件\文件夹,还有一个file_prompt和一个folder_prompt

These are available through the Variablesbutton on the (x)= Argumentstab 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} 将字符串添加到提示中,这将显示带有“请为我的提示文本输入值”的对话框。