用命令行启动java客户端,使用Java Web Start通过文件名在命令行上启动应用程序

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.(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 "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:

${com.prod.my.myapp.common.client.title}

I

${com.prod.my.myapp.common.client.description}

${com.prod.my.myapp.common.client.short_description}

解决方案

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 which results to file:.$$name and since no such file exists it fails.

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

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 (forward slashes).

All the best.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值