Netbeans how to set command line arguments in Java(Netbeans如何在Java中设置命令行参数)
问题描述
我正在尝试在 Windows 7 64 位上的 Netbeans 7.1 Java 项目中设置命令行参数.
I am trying to set command line arguments in a Netbeans 7.1 Java project on Windows 7 64 bit.
Netbeans 没有传递我给它的参数.
Netbeans is not passing the arguments I give it.
我转到 Project
--> Properties
--> Run
--> 并在Arguments"旁边键入参数,但是参数不传递给程序.我如何通过它们?
I go to Project
--> Properties
--> Run
--> and type the arguments next to "Arguments" however the arguments are not passed to the program. How do I pass them?
推荐答案
我猜你正在使用 Run |运行 File
(或 shift-F6)而不是 Run |运行主项目
.NetBeans 7.1 帮助文件(F1 是您的朋友!)Arguments 参数的状态:
I am guessing that you are running the file using Run | Run File
(or shift-F6) rather than Run | Run Main Project
. The NetBeans 7.1 help file (F1 is your friend!) states for the Arguments parameter:
添加参数以在应用程序执行期间传递给主类.请注意,参数不能传递给单个文件.
Add arguments to pass to the main class during application execution. Note that arguments cannot be passed to individual files.
我用一小段代码验证了这一点:
I verified this with a little snippet of code:
public class Junk
{
public static void main(String[] args)
{
for (String s : args)
System.out.println("arg -> " + s);
}
}
我将 Run -> Arguments 设置为 x y z
.当我自己运行文件时,我没有得到任何输出.当我运行项目时,输出是:
I set Run -> Arguments to x y z
. When I ran the file by itself I got no output. When I ran the project the output was:
arg -> x
arg -> y
arg -> z
这篇关于Netbeans如何在Java中设置命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Netbeans如何在Java中设置命令行参数


- 如何使用WebFilter实现授权头检查 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01