将命令行参数传递给javaws(Java WebStart)可执行文件 [英] Passing command line arguments to javaws (Java WebStart) executable

查看:530
本文介绍了将命令行参数传递给javaws(Java WebStart)可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那些可能不想阅读这些内容的人的总结:



我如何做到这一点?如果我们可以传递ad-hoc命令行参数到javaws,那么javaws应用程序可能更像一级公民普通应用程序。例如。我们可以传递要打开的文件的文件名。



我想知道是否有一种方法可以将ad-hoc命令行参数传递给javaws可执行文件。我已经知道如何在JNLP文件中指定它们:

 < application-desc main-class =org.example.ClassName > 
< argument> ...

虽然这可以用于我想要的完成,我把这作为解决方法。
我尝试了

  javaws http://example.org/launch.jnlp< some CLI args here> 

但是一些CLI参数在这里 b

如果我们可以通过ad-hoc命令行参数到javaws,那么javaws应用程序可能更像一级公民普通应用程序。例如。我们可以传递要打开的文件的文件名。
像eg

  javaws [options] http://example.org/launch.jnlp my_file.jpg 

在JNLP中硬编码的参数不满足此用例。

解决方案

没有什么可以混淆。



向任何JNLP发送命令行参数非常简单。



命令提示符> javaws -open空格arg1空格arg2 ...空格arg n JNLP url



例如:



c:\> javaws -open arg1 arg2 arg3 c:\myjnlp.jnlp



但是请记住一点,我们可以得到 -open 也作为 args [ 0] ,因此只需避免 args [0] 。此外,不能避免使用直接参数前缀为 - -open


Summary for those who might not want to read that much:

How do I do this: ? 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.

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>

But "some CLI args here" were just ignored, i think.

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

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.

To send the command line argument to any JNLP is very simple.

command prompt > javaws -open space arg1 space arg2 ... space arg n JNLP url

Ex:

c:\>javaws -open arg1 arg2 arg3 c:\myjnlp.jnlp

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)可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆