Netbeans的如何设置命令行参数在Java中 [英] Netbeans how to set command line arguments in Java
问题描述
我想设置的命令行参数在一个NetBeans 7.1 Java项目在Windows 7 64位。
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.
我去项目
- > 属性
- > 运行
- >并输入参数旁边的参数,然而参数不传递给程序。我如何通过他们?
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?
推荐答案
我猜您正在使用运行文件运行|运行文件
(或Shift-F6),而不是运行|运行主项目
。为参数参数在NetBeans 7.1的帮助文件(!F1是你的朋友)指出:
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.
我验证了这个与code的一个小片段:
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);
}
}
我设置运行 - >参数为 x和yž
。当我本身运行的文件我没有输出。当我跑项目的输出是:
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中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!