问题
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:
64-bit: https://osdn.net/projects/sfnet_runawfe/downloads/SRC%20and%20BIN%20files/extras/xulrunner-1.9.2.25-win64.zip/
32-bit: http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/24.0b10/runtimes/xulrunner-24.0b10.en-US.win32.zip
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);
}
}
来源:https://stackoverflow.com/questions/28945430/xulrunner-error-in-eclipse-swt