Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Eclipse RCP中的Firefox_Java_Firefox_Swt_Eclipse Rcp_Xulrunner - Fatal编程技术网

Java Eclipse RCP中的Firefox

Java Eclipse RCP中的Firefox,java,firefox,swt,eclipse-rcp,xulrunner,Java,Firefox,Swt,Eclipse Rcp,Xulrunner,我正在尝试使用Firefox作为我的SWT浏览器,它运行在我的EclipseRCP插件中 我已尝试使用以下代码加载XULRunner,我发现: 我正在使用Windows7x86和EclipseIndigo。我试过XULrunner 3.6.25和10。我使用的Firefox版本是10和22 无论哪个版本,它都会崩溃,并提供以下stacktrace: org.eclipse.swt.SWTError: XPCOM error -2147467259 at org.eclipse.swt.brows

我正在尝试使用Firefox作为我的SWT浏览器,它运行在我的EclipseRCP插件中

我已尝试使用以下代码加载XULRunner,我发现:

我正在使用Windows7x86和EclipseIndigo。我试过XULrunner 3.6.25和10。我使用的Firefox版本是10和22

无论哪个版本,它都会崩溃,并提供以下stacktrace:

org.eclipse.swt.SWTError: XPCOM error -2147467259
at org.eclipse.swt.browser.Mozilla.error(Mozilla.java:2502)
at org.eclipse.swt.browser.Mozilla.initXULRunner(Mozilla.java:2464)
at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:672)
at org.eclipse.swt.browser.Browser.<init>(Browser.java:99)
org.eclipse.swt.SWTError:XPCOM错误-2147467259
位于org.eclipse.swt.browser.Mozilla.error(Mozilla.java:2502)
位于org.eclipse.swt.browser.Mozilla.initXULRunner(Mozilla.java:2464)
位于org.eclipse.swt.browser.Mozilla.create(Mozilla.java:672)
在org.eclipse.swt.browser.browser上(browser.java:99)
如果在指向XULRunner的路径之前删除
文件://
,我会得到错误
c不是XULRunner 3.6.25中注册的协议

有人知道这个特定的XPCOM错误意味着什么以及如何修复它吗?

基于此,以下是让Firefox在Eclipse中为我工作的步骤:

  • 安装Ajax工具框架()
  • 在“运行配置…”->“插件”下添加
    org.mozilla.xulrunner
    org.mozilla.xulrunner.win32.win32.x86
  • 使用以下代码在swt.browser中启动Firefox:

    Bundle bundle = Platform.getBundle("org.mozilla.xulrunner"); //$NON-NLS-1$  
    if (bundle != null) {
        URL resourceUrl = bundle.getResource("xulrunner"); //$NON-NLS-1$
        if (resourceUrl != null) {
            try {
                URL fileUrl = FileLocator.toFileURL(resourceUrl);
                File file = new File(fileUrl.toURI());
                System.setProperty("org.eclipse.swt.browser.DefaultType",
                        "mozilla");
                System.setProperty(
                        "org.eclipse.swt.browser.XULRunnerPath", file.getAbsolutePath()); //$NON-NLS-1$
    
            } catch (IOException e) {
                e.printStackTrace();
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
        }
    } else {
        System.err.println("Could not find XULrunner bundle");
    }
    Browser webBrowser = new Browser(parent, SWT.MOZILLA);
    GridData grid = new GridData(GridData.FILL_BOTH);
    webBrowser.setLayoutData(grid);
    // Prepending "file://" prevents the "<driveletter> is not a registered protocol" error
    String graphUrl = "file://C:/Users/you/yourGraph.html"
    webBrowser.setUrl(graphUrl);
    
    Bundle=Platform.getBundle(“org.mozilla.xulrunner”)//$非NLS-1美元
    if(bundle!=null){
    URL resourceUrl=bundle.getResource(“xulrunner”);//$NON-NLS-1$
    if(resourceUrl!=null){
    试一试{
    URL fileUrl=FileLocator.toFileURL(resourceUrl);
    File File=新文件(fileUrl.toURI());
    System.setProperty(“org.eclipse.swt.browser.DefaultType”,
    “mozilla”);
    System.setProperty(
    “org.eclipse.swt.browser.XULRunnerPath”,文件.getAbsolutePath();//$NON-NLS-1$
    }捕获(IOE异常){
    e、 printStackTrace();
    }捕获(URISyntaxException e){
    e、 printStackTrace();
    }
    }
    }否则{
    System.err.println(“找不到XULrunner包”);
    }
    浏览器webBrowser=新浏览器(父级,SWT.MOZILLA);
    GridData grid=新的GridData(GridData.FILL\u两者);
    webBrowser.setLayoutData(网格);
    //在“file://”前面加上前缀可防止出现“不是已注册协议”错误
    String graphUrl=“file://C:/Users/you/yourGraph.html”
    webBrowser.setUrl(grapurl);
    
  • 在此基础上,以下是让Firefox在Eclipse中为我工作的步骤:

  • 安装Ajax工具框架()
  • 在“运行配置…”->“插件”下添加
    org.mozilla.xulrunner
    org.mozilla.xulrunner.win32.win32.x86
  • 使用以下代码在swt.browser中启动Firefox:

    Bundle bundle = Platform.getBundle("org.mozilla.xulrunner"); //$NON-NLS-1$  
    if (bundle != null) {
        URL resourceUrl = bundle.getResource("xulrunner"); //$NON-NLS-1$
        if (resourceUrl != null) {
            try {
                URL fileUrl = FileLocator.toFileURL(resourceUrl);
                File file = new File(fileUrl.toURI());
                System.setProperty("org.eclipse.swt.browser.DefaultType",
                        "mozilla");
                System.setProperty(
                        "org.eclipse.swt.browser.XULRunnerPath", file.getAbsolutePath()); //$NON-NLS-1$
    
            } catch (IOException e) {
                e.printStackTrace();
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
        }
    } else {
        System.err.println("Could not find XULrunner bundle");
    }
    Browser webBrowser = new Browser(parent, SWT.MOZILLA);
    GridData grid = new GridData(GridData.FILL_BOTH);
    webBrowser.setLayoutData(grid);
    // Prepending "file://" prevents the "<driveletter> is not a registered protocol" error
    String graphUrl = "file://C:/Users/you/yourGraph.html"
    webBrowser.setUrl(graphUrl);
    
    Bundle=Platform.getBundle(“org.mozilla.xulrunner”)//$非NLS-1美元
    if(bundle!=null){
    URL resourceUrl=bundle.getResource(“xulrunner”);//$NON-NLS-1$
    if(resourceUrl!=null){
    试一试{
    URL fileUrl=FileLocator.toFileURL(resourceUrl);
    File File=新文件(fileUrl.toURI());
    System.setProperty(“org.eclipse.swt.browser.DefaultType”,
    “mozilla”);
    System.setProperty(
    “org.eclipse.swt.browser.XULRunnerPath”,文件.getAbsolutePath();//$NON-NLS-1$
    }捕获(IOE异常){
    e、 printStackTrace();
    }捕获(URISyntaxException e){
    e、 printStackTrace();
    }
    }
    }否则{
    System.err.println(“找不到XULrunner包”);
    }
    浏览器webBrowser=新浏览器(父级,SWT.MOZILLA);
    GridData grid=新的GridData(GridData.FILL\u两者);
    webBrowser.setLayoutData(网格);
    //在“file://”前面加上前缀可防止出现“不是已注册协议”错误
    String graphUrl=“file://C:/Users/you/yourGraph.html”
    webBrowser.setUrl(grapurl);
    

  • 谷歌搜索“SWTError:XPCOM错误”的第一个结果:@Baz:谢谢。在我看来,所描述的bug是一个64位问题。但是我的环境是纯32位的。第一个谷歌搜索结果是“SWTError:XPCOM错误”:@Baz:Thank。在我看来,所描述的bug是一个64位问题。但是我的环境是纯32位的。