使用Java web start通过文件名在命令行启动应用程序

发布于 2024-10-15 11:47:45 字数 4789 浏览 6 评论 0原文

我可以使用 Java web start 在命令行上通过 jdk 6 & 的 url 启动我的 Swing GUI 应用程序。 Windows XP: javaws http://localhost:7001/webstart/myapp/launch.jnlp

使用方法Java web start 通过文件名在命令行上启动我的 Swing GUI 应用程序?

以下方法不起作用: javaws -codebase '' launch.jnlp java.net.MalformedURLException:无协议:'' 位于 java.net.URL。(来源不明) 位于 java.net.URL。(来源不明) 位于 java.net.URL。(来源不明) 在 com.sun.javaws.Main.parseArgs(来源未知) 在 com.sun.javaws.Main.continueInSecureThread(来源未知) 在 com.sun.javaws.Main$1.run(来源未知) 在java.lang.Thread.run(未知来源)的

javaws -codebase "" launch.jnlp
java.net.MalformedURLException: unknown protocol: c
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at com.sun.javaws.Main.parseArgs(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

javaws -codebase "file:." launch.jnlp
com.sun.deploy.net.FailedDownloadException: Unable to load resource: file:./$$name
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
    at com.sun.javaws.Launcher.updateFinalLaunchDesc(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.launch(Unknown Source)
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

javaws -codebase "file:." file://launch.jnlp
CouldNotLoadArgumentException[ Could not load file/URL specified: file://launch.jnlp]
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

javaws file://launch.jnlp 
CouldNotLoadArgumentException[ Could not load file/URL specified: file://launch.jnlp]
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

#The following has no error message, but nothing appear on the computer screen:
javaws -codebase "" -J-Xrunjdwp:transport=dt_socket launch.jnlp
javaws -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,server=n,suspend=y launch.jnlp
javaws -codebase "" -J-Xrunjdwp:transport=dt_socket,server=n,suspend=n launch.jnlp
javaws -codebase "" -J-Xrunjdwp:transport=dt_socket,server=y,suspend=n launch.jnlp

launch.jnlp文件如下:

<?xml version="1.0" encoding="utf-8"?> 

<jnlp spec="1.0+" codebase="$$codebase" href="$$name"> 

  <information> 
    <title>${com.prod.my.myapp.common.client.title}</title> 
    <vendor>I</vendor> 
    <homepage href="http://devzone/english/dev%20template/html_templates/main.asp"/> 
    <description>${com.prod.my.myapp.common.client.description}</description> 
    <description kind="short">${com.prod.my.myapp.common.client.short_description}</description> 
    <icon href="$$context/images/chflag.jpg"/> 
  </information> 

  <security> 
      <all-permissions/> 
  </security> 

  <resources> 

  <java version="1.6.0_05" href="http://java.sun.com/products/autodl/j2se" max-heap-size="256m"/> 

    <!-- myapp Application --> 
    <jar href="myprod.myapp.client.jar"/> 
    <jar href="myprod.reports.jar"/> 

    <!-- TR Client jar --> 
    <jar href="extern.ejb-client.jar"/> 

    <property name="java.naming.factory.initial" value="weblogic.jndi.WLInitialContextFactory"/> 
    <property name="java.naming.provider.url" value="${com.prod.my.myapp.common.client.naming_provider}"/> 
    <property name="weblogic.jndi.enableServerAffinity" value="true" / 

  </resources> 

  <application-desc main-class="com.prod.my.myapp.common.framework.applicationmainwindow.gui.myappAp­plication"/ 

</jnlp> 

I can use Java web start to start my Swing GUI application on the command line by the url with jdk 6 & Windows XP:
javaws http://localhost:7001/webstart/myapp/launch.jnlp

How to use Java web start to start my Swing GUI application on the command line by the file name?

The following ways do not work:
javaws -codebase '' launch.jnlp
java.net.MalformedURLException: no protocol: ''
at java.net.URL.(Unknown Source)
at java.net.URL.(Unknown Source)
at java.net.URL.(Unknown Source)
at com.sun.javaws.Main.parseArgs(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

javaws -codebase "" launch.jnlp
java.net.MalformedURLException: unknown protocol: c
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at com.sun.javaws.Main.parseArgs(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

javaws -codebase "file:." launch.jnlp
com.sun.deploy.net.FailedDownloadException: Unable to load resource: file:./$name
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
    at com.sun.javaws.Launcher.updateFinalLaunchDesc(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.launch(Unknown Source)
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

javaws -codebase "file:." file://launch.jnlp
CouldNotLoadArgumentException[ Could not load file/URL specified: file://launch.jnlp]
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

javaws file://launch.jnlp 
CouldNotLoadArgumentException[ Could not load file/URL specified: file://launch.jnlp]
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

#The following has no error message, but nothing appear on the computer screen:
javaws -codebase "" -J-Xrunjdwp:transport=dt_socket launch.jnlp
javaws -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,server=n,suspend=y launch.jnlp
javaws -codebase "" -J-Xrunjdwp:transport=dt_socket,server=n,suspend=n launch.jnlp
javaws -codebase "" -J-Xrunjdwp:transport=dt_socket,server=y,suspend=n launch.jnlp

The launch.jnlp file is as follows:

<?xml version="1.0" encoding="utf-8"?> 

<jnlp spec="1.0+" codebase="$codebase" href="$name"> 

  <information> 
    <title>${com.prod.my.myapp.common.client.title}</title> 
    <vendor>I</vendor> 
    <homepage href="http://devzone/english/dev%20template/html_templates/main.asp"/> 
    <description>${com.prod.my.myapp.common.client.description}</description> 
    <description kind="short">${com.prod.my.myapp.common.client.short_description}</description> 
    <icon href="$context/images/chflag.jpg"/> 
  </information> 

  <security> 
      <all-permissions/> 
  </security> 

  <resources> 

  <java version="1.6.0_05" href="http://java.sun.com/products/autodl/j2se" max-heap-size="256m"/> 

    <!-- myapp Application --> 
    <jar href="myprod.myapp.client.jar"/> 
    <jar href="myprod.reports.jar"/> 

    <!-- TR Client jar --> 
    <jar href="extern.ejb-client.jar"/> 

    <property name="java.naming.factory.initial" value="weblogic.jndi.WLInitialContextFactory"/> 
    <property name="java.naming.provider.url" value="${com.prod.my.myapp.common.client.naming_provider}"/> 
    <property name="weblogic.jndi.enableServerAffinity" value="true" / 

  </resources> 

  <application-desc main-class="com.prod.my.myapp.common.framework.applicationmainwindow.gui.myappAp­plication"/ 

</jnlp> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寄与心 2024-10-22 11:47:45

尝试使用代码库值..

"file:."

Try a codebase value of..

"file:."
四叶草在未来唯美盛开 2024-10-22 11:47:45

看来您的 JNLP 文件应该与 一起使用JNLPDownloadServlet。它会将 $$name$$codebase 占位符替换为基于应用程序当前运行的服务器的当前值。 (顺便说一句,您还可以使用 $$server 来引用当前服务器)

如​​果您从磁盘本地运行它,则可以通过在命令行上设置来覆盖 codebase作为参数-codebase。正确的值为file:.。您的问题是 $$name 占位符未被替换,并且它尝试下载 ,结果为file:.$$name 并且由于不存在这样的文件,因此失败。

您可以在本地运行时完全省略 标记中的 href="$$name" 属性,也可以手动将其更改为 jnlp 文件名,例如

另请记住,如果您想使用存储在磁盘上的某些本地 jar 并且希望通过绝对路径引用它,您应该使用此格式 (正斜杠)。

一切顺利。

It seems your JNLP file should be used together with the JNLPDownloadServlet. It replaces the $$name and $$codebase palceholders with the current values based on the server where you application currently runs. (Btw. you can also use $$server to refer the current server)

If you run it locally from disk, you can overwrite the codebase by setting it on the command line as parameter -codebase. The right value is file:.. You problem is that the $$name placeholder is not replaced and it tries do download the <jnlp ... href="$$name"> which results to file:.$$name and since no such file exists it fails.

You can either completely omitt the href="$$name" attribute in the <jnlp /> tag when running locally or manually change it to the jnlp file name e.g. <jnlp ... href="myApp.jnlp" />.

Also remeber if you want to use some local jar stored on you disk and you want to refer it via absolute path you should use this format <jar href="file:c:/myJars/myJar.jar"> (forward slashes).

All the best.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文