Exception in thread "main" org.eclipse.swt.SWTError: XPCOM error 0x80004005 in swt.mozilla
Asked Answered
C

1

1

following my SWT code which use Mozilla browser but it gives me an error xpcomm error 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.

Charland answered 28/6, 2017 at 13:11 Comment(3)
What version of SWT and what version of XULRunner are you using? Have you seen this post: Creating a SWT.MOZILLA browser on Windows 64 bit and SWT 4.3? Without a bit more detail I can't tell whether or not this is a duplicate.Strasbourg
Hi thanks for comment, i am using SWT 4.5.2 and Xulrunner 10.X in windows 64 bitCharland
@Strasbourg please help me for thisCharland
S
1

From the notes on using XULRunner here, it looks like using version 10.x is correct.

I was able to get your code running by downloading XULRunner 10.0.4esr. I followed the installation steps given in this answer, as well as pointing to the bin directory specifically.

  1. Download xulrunner-10.0.4esr.en-US.win32.sdk.zip from this directory
  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.
  3. Either use the VM argument (-Dorg.eclipse.swt.browser.XULRunnerPath), or use System.setProperty() as you are currently. Be sure that the path that you specify points to the bin directory, not just the top level xulrunner directory.

Make sure you have that version of XULRunner (and specifically the SDK), and verify that the file path you are pointing to exists. 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.


Edit: I just realized I was doing this with 32-bit libraries (32-bit Java and 32-bit SWT). So if you're by any chance using 32-bit libraries, this should work. 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.


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/

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.

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

Strasbourg answered 30/6, 2017 at 14:30 Comment(3)
yes it is working with 32-bit libraries (32-bit Java and 32-bit SWT) ,but what about 64 bit libraries? i was still not able to get this on 64 bit libraries.Charland
@Bhavikpatel See my second edit - I found the contents of the bin directory for a win64 version of xulrunner and was able to run your code.Strasbourg
@Bhavikpatel Was this able to help at all?Strasbourg

© 2022 - 2024 — McMap. All rights reserved.