XULRunner error in Eclipse / SWT

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

I'm trying to run the Enhanced JavaScript Bridge example found here.

I created a new project, and added a reference to SWT via:

Project(right-click)-->Properties-->Libraries-->Add Variable-->Configure Variable-->New

However I cannot get this project to run. The error I get depends on what SWT library I'm referencing:

  • org.eclipse.swt.win32.win32.x86_64_3.103.2.v20150203-1351.jar: Error is

Could not instantiate Browser: org.eclipse.swt.internal.mozilla.init.XPCOMInit.GREVersionRange_sizeof()I

  • swt-3.6.1-win32-win32-x86_64\swt.jar: Error is

Could not instantiate Browser: No more handles [Could not detect registered XULRunner to use]

It seems I am having a problem with XULRunner or the Mozilla browser. I tried using different XULRunner versions (10, 18, 24) by running xulrunner.exe --register-global in the console in their respective folders. It didn't help. I don't know what else to do.

My system is:

  • Windows 7 64-bit
  • Eclipse Luna 4.4.2

回答1:

Ok, so I managed to get XULRunner working in the following way:

1) Download XULrunner 24.0. You can find the versions I used here:

2) In my Java code I create a Composite to contain my Browser object.

In its constructor I set the path to the xulrunner folder I downloaded in step 1, and then instantiate the browser:

public class MyBrowserComp extends Composite {      private String pathToXulrunner = "C:\\path\\to\\xulrunner";`      private Browser browser;      public MyBrowserComp(..) {         System.setProperty("org.eclipse.swt.browser.XULRunnerPath", pathToXulrunner);         browser = new Browser(this, SWT.MOZILLA);     } } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!