问题描述
给那些可能不想阅读那么多的人的总结:
Summary for those who might not want to read that much:
我想知道是否有办法将ad-hoc"命令行参数传递给 javaws 可执行文件.我已经知道如何在 JNLP 文件中指定它们:
I would like to know if there is a way to pass "ad-hoc" command line arguments to the javaws executable. I already know how to specify them in JNLP file:
<application-desc main-class="org.example.ClassName">
<argument>...
虽然这可以用于我想要完成的事情,但我将此视为一种解决方法.我试过
While this can be used for what i want to accomplish, i treat this as a workaround.I tried
javaws http://example.org/launch.jnlp <some CLI args here>
但是我认为这里有一些 CLI 参数"被忽略了.
But "some CLI args here" were just ignored, i think.
如果我们可以将 ad-hoc 命令行参数传递给 javaws,那么 javaws 应用程序可能更像是一等公民"普通应用程序".例如.我们可以传递要打开的文件的文件名.像例如
If we could pass ad-hoc command-line args to javaws, then javaws apps could be more like "1st class citizen" "ordinary application". E.g. we could pass filenames of files to be opened.Like e.g.
javaws [options] http://example.org/launch.jnlp my_file.jpg
在 JNLP 中硬编码参数不能满足这个用例.
Having arguments hardcoded in JNLP does not satisfy this use case.
推荐答案
没有什么可混淆的.我测试过的非常直接的答案,效果很好.
There is nothing to confuse. The very straight answer which I tested and it is working perrfect.
向任何 JNLP 发送命令行参数非常简单.
To send the command line argument to any JNLP is very simple.
命令提示符> javaws -open space arg1 space arg2 ... space arg n JNLP url
例如:
c:\>javaws -open arg1 arg2 arg3 c:\myjnlp.jnlp
但是请记住一件事,我们可以在main方法中将-open
也作为args[0]
,所以只要避免args[0].也无法避免
-open
直接参数以 -
为前缀.
But remember one thing, We can get the
-open
also as args[0]
in main method, so just avoid args[0]
. Also it is not possible to avoid -open
with direct argument prepixed with -
.
这篇关于将命令行参数传递给 javaws (Java WebStart) 可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!