java 如何使用 JNLP 将命令行参数传递给应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14116640/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 15:07:55  来源:igfitidea点击:

How to use JNLP to pass command line arguments to the application?

javaargumentsjnlpjava-web-start

提问by reza

I have a JNLP package for my application. Now I have the need to pass command line arguments to my application. How do I extend my JNLP file to list the command line arguments?

我的应用程序有一个 JNLP 包。现在我需要将命令行参数传递给我的应用程序。如何扩展我的 JNLP 文件以列出命令行参数?

For instance, I need to say java main.class arg1 arg2and the arg1and arg2need to be mentioned as part of JNLP file.

举例来说,我需要说java main.class arg1 arg2arg1,并arg2需要一提的是JNLP文件的一部分。

回答by Andrew Thompson

Look to the description of the application-descElementfor further details of the argumentelement.

有关application-desc元素的更多详细信息,请查看元素的描述argument

The applicationelement indicates that the JNLP file is launching an application (as opposed to an applet). ..

Arguments can be specified to the application by including one or more nested argumentelements.
For example:

application元素表示 JNLP 文件正在启动应用程序(与小程序相反)。..

可以通过包含一个或多个嵌套argument元素来为应用程序指定参数。
例如:

  <application-desc main-class="Main">
    <argument>arg1</argument>
    <argument>arg2</argument>
  </application-desc>