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中设置命令行参数
基础教程推荐
- Struts2 URL 无法访问 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
