ServiceManager.getServiceNames()返回null。为什么?

时间:2013-10-25 12:36:45

标签: java jnlp

我有一个能够保存和加载文件的小应用程序。然后我决定尝试使用Java Web Start,因此我需要将JFileChooser用法重写为jnlp。

http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/components/JWSFileChooserDemoProject/src/components/JWSFileChooserDemo.java我试图重写我的代码。

这是我带来的

FileSaveService fss = null;
FileContents fileContents = null;
ByteArrayInputStream is = new ByteArrayInputStream(
    (new String("Saved by JWSFileChooserDemo").getBytes()));
try {
    String[] services = ServiceManager.getServiceNames();
    fss = (FileSaveService)ServiceManager.
                    lookup("javax.jnlp.FileSaveService");
}
catch (UnavailableServiceException exc) { }

if (fss != null) {
    try {
        fileContents = fss.saveFileDialog(null, null, is, null);
}

等等。

首先没有ServiceManager.getServiceNames调用,而我ServiceManager.lookup返回null。所以我决定获取服务列表,getServiceNames也返回null。

如何才能找到FileSaveService?该方法在哪里查找此服务,我不应该在某处写一些额外的东西来声明我需要该服务?

UPD:我试图从上面的oracle链接运行JWSFileChooserDemo,但它不起作用。与返回null的ServiceManager.lookup相同。

0 个答案:

没有答案
相关问题