我通常通过运行配置在Eclipse中输入命令行参数。但是我不知道如何在IntelliJ IDEA中实现同样的任务。
当前回答
自IntelliJ IDEA 2021年以来,我对这个问题添加了更新的答案。
Select Edit Configuration from the toolbar (or under the Run menu): Picture of new location of edit configuration box You now have to click on the Modify Options menu (Alt + M) to the left of where it says Build and Run, and above the drop down menu that lets you select the version of Java (or other language) that your using. After you click Modify Options the first box you will see--titled Operating System--will have a line that says "Redirect input". Click on that to add the box for input redirection. Close Modify Options. Under Build and Run, the third box down is for command line input.
Intelij IDE的图片与编辑配置框打开箭头指向cmd行输入和输入重定向
这就是它的全部。
其他回答
如果你正在使用intellij去运行>编辑配置菜单设置。将出现一个对话框。现在您可以向Program arguments输入字段添加参数。
在IntelliJ中,如果您想将args参数传递给main方法。
执行->编辑配置
程序参数:5 10 25
您需要通过分隔的空格传递参数,然后单击apply并保存。
现在如果要打印,就运行程序
System.out.println (args [0]); System.out.println (args [1]); System.out.println (args [2]); 输出是5 10 25
只需左键单击当前配置(我的是主),并选择编辑配置,
然后在输入字段中,程序参数输入您的值,就像在控制台中一样,单击OK。
我有一个类Test:
然后。转到配置运行类Test:
步骤1:添加应用
步骤2:
您可以在“程序参数”文本框中输入参数。
做以下步骤:-
进入运行-编辑配置->应用程序(在面板左侧)->选择你想要运行的scala应用程序->程序参数
推荐文章
- Android Studio中的。iml文件是什么?
- 如何触发命令行PHP脚本的XDebug分析器?
- Rust中的默认函数参数
- 为什么IntelliJ 13 IDEA从12版本升级后这么慢?
- Maven命令行如何指向特定的settings.xml为单个命令?
- 如何循环通过文件匹配通配符在批处理文件
- intellij是否可以像在Eclipse中那样组织导入?
- 我怎么能显示线在公共(反向差异)?
- 导入时无法解析符号
- 如何从IntelliJ IDEA搜索中排除文件扩展名?
- Git显示“警告:永久添加到已知主机列表”
- 我如何找到传递给Bash脚本的参数的数量?
- IntelliJ IDEA输出窗口切割输出
- 在函数中使用默认实参
- 如何让IntelliJ识别常见的Python模块?