开发者

Get server address in Java Web Start

How can I get server ip开发者_运维知识库 address in my JavaWS application, from which it was downloaded?

Thanks!


I guess, use BasicService.getCodeBase.


You'll need to get ahold of jnlp.jar and add it to your application. I had to find it in the JDK samples and demos, which are distributed separately from the JDK. I used this samples and demos question to find it. I was able to get ahold of it with a URL like http://download.oracle.com/otn-pub/java/jdk/8u11-b12-demos/jdk-8u11-windows-i586-demos.zip

With jnlp.jar on your classpath, use this code to get the URL of your application's codebase, which you can use to find the server hostname.

import javax.jnlp.*;

BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
URL codebase = bs.getCodeBase();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜