简体   繁体   English

线程“主” org.eclipse.swt.SWT中的异常错误:swt.mozilla中的XPCOM错误0x80004005

[英]Exception in thread “main” org.eclipse.swt.SWTError: XPCOM error 0x80004005 in swt.mozilla

following my SWT code which use Mozilla browser but it gives me an error xpcomm error 0x80004005. 遵循使用Mozilla浏览器的SWT代码,但它给我一个错误xpcomm错误0x80004005。

import java.awt.GridLayout;
import java.io.File;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.internal.dnd.SwtUtil;

public class Newbrowser {
    public static void main(String a[]) {
        Display display = new Display();
        Shell shell = new Shell(display);
        /* Composite controls = new Composite(shell, SWT.NONE); */
        shell.setText("Browser");
        String pathToXulrunner = "C://Program Files (x86)/Mozilla XULRunner/";

        System.setProperty("org.eclipse.swt.browser.XULRunnerPath", pathToXulrunner);

        /*
         * System.setProperty("org.eclipse.swt.browser.XULRunnerPath",
         * pathToXulrunner);
         */
        System.setProperty("org.eclipse.swt.browser.MOZ_PROFILE_PATH", new File("").getAbsolutePath());
        Browser browser = new Browser(shell, SWT.MOZILLA);
        shell.setLayout(new FillLayout());
        shell.open();

        FormData data = new FormData();

        data.top = new FormAttachment(0, 0);
        data.bottom = new FormAttachment(100, 0);
        data.left = new FormAttachment(0, 0);
        data.right = new FormAttachment(100, 0);
        browser.setLayoutData(data);
        browser.setUrl("www.google.com");

        // Set up the event loop.

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                // If no more entries in the event queue
                display.sleep();
            }
        }
        display.dispose();
    }
}

Please help me to solve this problem. 请帮我解决这个问题。 thanks in advance. 提前致谢。

From the notes on using XULRunner here , it looks like using version 10.x is correct. 此处使用XULRunner的注意事项来看,似乎使用10.x版是正确的。

I was able to get your code running by downloading XULRunner 10.0.4esr . 通过下载XULRunner 10.0.4esr,我可以使您的代码运行。 I followed the installation steps given in this answer , as well as pointing to the bin directory specifically. 我按照此答案中给出的安装步骤进行操作,并特别指向bin目录。

  1. Download xulrunner-10.0.4esr.en-US.win32.sdk.zip from this directory 从此目录下载xulrunner-10.0.4esr.en-US.win32.sdk.zip
  2. Extract the contents and move the xulrunner directory to some location (I used c:/xulrunner , but in your case C:/Program Files (x86)/XULRunner should be fine too. 提取内容并将xulrunner目录移动到某个位置(我使用c:/xulrunner ,但是在您的情况下, C:/Program Files (x86)/XULRunner应该很好。
  3. Either use the VM argument ( -Dorg.eclipse.swt.browser.XULRunnerPath ), or use System.setProperty() as you are currently. 您可以使用VM参数( -Dorg.eclipse.swt.browser.XULRunnerPath ),也可以使用System.setProperty() Be sure that the path that you specify points to the bin directory, not just the top level xulrunner directory. 确保您指定的路径指向bin目录,而不仅仅是顶层xulrunner目录。

Make sure you have that version of XULRunner (and specifically the SDK), and verify that the file path you are pointing to exists. 确保您具有该版本的XULRunner(尤其是SDK),并验证您指向的文件路径是否存在。 Depending on where you unzip the download, you may need to replace: 根据您将下载文件解压缩的位置,您可能需要替换:

String pathToXulrunner = "C://Program Files (x86)/Mozilla XULRunner/";

with: 有:

String pathToXulrunner = "C:/Program Files (x86)/Mozilla XULRunner/bin";

I'm also running 64-bit Windows 10 with SWT 4.5.2, so we should have the same setup. 我还在运行带有SWT 4.5.2的64位Windows 10,因此我们应该具有相同的设置。


Edit: I just realized I was doing this with 32-bit libraries (32-bit Java and 32-bit SWT). 编辑:我刚刚意识到我正在使用32位库(32位Java和32位SWT)执行此操作。 So if you're by any chance using 32-bit libraries, this should work. 因此,如果您偶然使用32位库,则应该可以使用。 According to this answer you should be able to use XULRunner 24 with a 64-bit JRE, however I was not able to get this working. 根据此答案,您应该能够将XULRunner 24与64位JRE一起使用,但是我无法使它正常工作。


Edit 2: For 64-bit libraries, I found the contents of the bin directory for xulrunner-1.9.2.25 here: https://osdn.net/projects/sfnet_runawfe/downloads/SRC%20and%20BIN%20files/extras/xulrunner-1.9.2.25-win64.zip/ 编辑2:对于64位库,我在这里找到xulrunner-1.9.2.25的bin目录的内容: https ://osdn.net/projects/sfnet_runawfe/downloads/SRC%20and%20BIN%20files/extras/xulrunner -1.9.2.25-win64.zip/

With this downloaded, I was able to run your code. 下载此文件后,我就可以运行您的代码了。 Note that this is the contents of the bin directory (equivalent to downloading the runtimes instead of the SDK), so you can exclude the bin from your file path for pathToXulrunner . 请注意,这是bin目录的内容(等同于下载运行pathToXulrunner不是SDK),因此您可以从pathToXulrunner的文件路径中排除bin

I can't right this minute, but I'll host this somewhere else and update the post later. 这分钟我不能正确,但是我将在其他地方托管它,并在以后更新帖子。


Edit 3: I've re-hosted this as xulrunner-1.9.2.25.en-US.win64.zip 编辑3:我已将其重新托管为xulrunner-1.9.2.25.en-US.win64.zip

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android SDK和AVD管理器无法打开。 “线程'main'org.eclipse.swt.SWTError中的异常:无法设置文本” - Android SDK and AVD manager not opening. “Exception in thread 'main' org.eclipse.swt.SWTError: Cannot set text” Windows Jenkins 服务 org.eclipse.swt.SWTError:没有更多句柄 - Windows Jenkins service org.eclipse.swt.SWTError: No more handles 使用Java Web Start启动Eclipse应用程序会生成java.lang.ClassNotFoundException:org.eclipse.swt.SWTError - Launching eclipse application with java web start generates java.lang.ClassNotFoundException: org.eclipse.swt.SWTError NoClassDefFoundError org / eclipse / swt / SWTError - NoClassDefFoundError org/eclipse/swt/SWTError SWT错误:线程“主”中的异常java.lang.NoClassDefFoundError:org / eclipse / swt / graphics / Device - SWT Error: Exception in thread “main” java.lang.NoClassDefFoundError: org/eclipse/swt/graphics/Device 运行jar时的SWT异常:线程“main”中的异常org.eclipse.swt.SWTException:无效的线程访问 - SWT Exception when running jar: Exception in thread “main” org.eclipse.swt.SWTException: Invalid thread access Java SWT在“主”线程中具有maven异常java.lang.NoClassDefFoundError:org / eclipse / swt / widgets / Composite - Java SWT with maven Exception in thread “main” java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Composite 如何在Java中修复“主线程” java.lang.NoClassDefFoundError:org / eclipse / swt / SWT中的异常 - How to fix 'Exception in thread “main” java.lang.NoClassDefFoundError: org/eclipse/swt/SWT' in Java 在Windows 64位和SWT 4.3上创建SWT.MOZILLA浏览器 - Creating a SWT.MOZILLA browser on Windows 64 bit and SWT 4.3 Windows 8 64位版本的浏览器类型SWT.MOZILLA出现问题 - Trouble with Browser type SWT.MOZILLA on windows 8 64 bit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM