更新时间:2023-11-29 17:54:16
我猜你正在使用 Run | 运行文件运行文件
(或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