1
我无法在swt浏览器中加载jar:file
uri。相同的uri在我的Firefox中加载得很好,并且它可以加载相同软件的旧版本。我可以发现的唯一变化是旧的工作版本取决于 - 看起来没有理由 - 在org.eclipse.core.resources
。 但是,重新创建依赖关系后,页面仍然无法加载。如何在swt浏览器中加载jar:file:uri?
我有这样的浏览器窗口:
Unable to load page
Problem occurred while loading the URL file:///usr/share/zenta/plugins/org.rulez.magwas.zenta.help_2.4.0.201401091630.jar!/hints/viewpoint_total.html
Error opening file: No such file or directory
我没有发现任何异常的迹象,并在日志中没有痕迹。
在上述情况下的实际URI是:
jar:file:/usr/share/zenta/plugins/org.rulez.magwas.zenta.help_2.4.0.201401091630.jar!/hints/viewpoint_total.html
我使用这个代码:
win.shell.pack();
win.shell.open();
Browser fBrowser = new Browser(win.getComposite(), SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
fBrowser.setLayoutData(gd);
fBrowser.pack();
String cwd = System.getProperty("user.dir");
String url = "jar:file:/usr/share/zenta/plugins/org.rulez.magwas.zenta.help_2.4.0.201401091630.jar!/hints/viewpoint_total.html"
System.out.printf("cwd=%s\nurl=%s\n", cwd, url);
fBrowser.setUrl(url);
fBrowser.setFocus();
至于奖金的问题:有没有办法来检测浏览器的这种故障,所以当找到解决方案时,我可以为它编写单元测试?
其实这个问题不是由于不同的版本,但不同的版本。 看来swt浏览器永远无法打开这样的网址(而mozilla是)。 有问题的网址来自我的其中一个包。在eclipse版本中,有问题的捆绑包被打包为一个目录,而在maven版本中,它被打包为jar,因为tycho忽略root.folder属性。 但是我可以将Eclipse-BundleShape:dir添加到由tycho执行的MANIFEST.MF。 感谢您的回答。 –