I have a single application t开发者_JAVA百科hat I am deploying via Java web Start. I have several different jnlp files for different launch scenarios. I am using DownloadService2 to check for updates periodically. When an update is available, I prompt the user. If they elect to update, I launch a new instance of javaws using Runtime.getRuntime().exec(), passing in the full jnlp url, then I System.exit(0). Effectively, this kicks off an update/restart cycle.
The problem is, since I could have started from one of several jnlp files, I can't simply hardcode the url. I know that I can get the host:port portion of the url from BasicService.getCodeBase(), but is there a way to get the file portion of the url? Currently I am adding a "jnlp" argument to the application-desc similar to the following so that I can retrieve it from args:
<application-desc main-class="my.main.class">
<argument>jnlp=myjnlp.jnlp</argument>
<application-desc/>
I think this will work, but I'm wondering if I am making it harder than it needs to be. Thanks.
Perhaps it would be best to provide this functionality using the DownloadService.
I worked around this issue using the approach described in my question. There doesn't seem to be a better way.
精彩评论