如何在JNLP参数中使用变量 [英] How to use variables in JNLP arguments

查看:151
本文介绍了如何在JNLP参数中使用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有以下示例jnlp:

Having the following sample jnlp:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="$$codebase" href="$$name">
    <information>
        <title>Some Example</title>
        <vendor>Some Sample Vendor</vendor>
        <homepage href="http://www.somesamplevendorhomepage.com"/>
        <description>Some Sample Description</description>
        <icon kind="splash" href="link_to_some_splash.jpg"/>
        <offline-allowed/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <update check="always" policy="always"/> 
    <application-desc main-class="com.some.sample.Main">
        <argument>--URL=SAMPLE_DB_NAME=http://localhost:<db_port>/webapplication/creds/auth</argument>
        <argument>--UserTimeout=350</argument> 
    </application-desc>
    <resources>
        <j2se version="1.7+" />
        <jar href="com.some.sample_1.0.0.jar"/>
        .
        .
        .
    </resources>
</jnlp>

(请忽略格式或其他不一致之处-唯一重要的部分是参数部分)

(please ignore formatting or other inconsistencies - the only part that matters is the argument part)

argument 标记内包含变量 db_port ,当使用 javaws 执行jnlp时,有一种方法可以将值传递给该变量?

Having the variable db_port within the argument tag, is there a way to pass a value to this variable when executing the jnlp with javaws?

例如: javaws/path/to/sample.jnlp 31022

JNLP将JAR下载到位于AppData \ LocalLow \ Sun \ Java \ Deployment \ cache下的(在Windows上)缓存文件夹中. 有没有一种方法可以使用下载的JAR(我的应用程序具有多个JAR文件)来执行直接向下载的JAR提供参数的应用程序?

JNLP downloads the JARs to the cache folder located (on Windows) under AppData\LocalLow\Sun\Java\Deployment\cache. Is there a way to use the download JARs (my app has multiple JAR files) in order to have a way to execute the app providing the argument directly to the downloaded JAR?

例如:

jar -jar app.jar --URL=SAMPLE_DB_NAME=http://localhost:<db_port>/webapplication/creds/auth


PS:我了解到缓存文件夹中存储的文件具有计算出的生成名称,并且没有.jar扩展名. 但是,从Java控制面板GUI或带有"javaws -viewer"的CMD/PS,我能够确定用作jnlp的文件并启动它.我想知道是否可以使用某些JAR来启动该应用程序,或者创建一个父"应用程序以便能够向其传递参数.


PS: I understand that the files that are stored in the cache folder have a computed generated name and they are without the .jar extension. However from the Java Control Panel GUI or from CMD/PS with "javaws -viewer" I was able to determine the file used as jnlp and launch it. I was wondering if there is a way to use some of the JARs to launch the app or maybe create a "parent" one in order to be able to pass arguments to it.

推荐答案

文档似乎是

The documentation seems to be intentionally lacking on this topic, but the documentation suggests the preferred method to pass command line parameters to the javaws executable is through ‑userConfig flag.

例如

javaws /path/to/sample.jnlp -userConfig port 31022

文档没有为此提供示例.我什至在GitHub上搜索了javaws userConfig,但只得到了极少数结果,因此这似乎是很少使用的功能.

The documentation doesn't provide examples for this. I even searched GitHub for javaws userConfig and only got a handful of results, so this seems to be a very rarely used feature.

由于您的问题专门询问另一个变量中包含的<port>变量,因此不直接支持该变量.相反,您需要找到一种方法来使用通配符或对<port>进行参数化,方法是使用一个附加变量并在主类中进行一些搜索/替换,前提是您有权访问源代码.如果您无权访问源代码,则将不得不手工编写JNLP,如果它是

Since your question specifically asks about a <port> variable contained within another variable, that is not something directly supported. You would instead need to find a way to wildcard or paramaterize the <port> using an additional variable and some search/replace inside the main class, assuming you have access to the source. If you don't have access to the source, you will be stuck writing the JNLP by hand, which can have additional work required if it's a signed file.

这篇关于如何在JNLP参数中使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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