![](/img/trans.png)
[英]Creating a SWT.MOZILLA browser on Windows 64 bit and SWT 4.3
[英]XPCOM error in maven SWT project on windows 10 64 bit
我正在嘗試使用MOZILLA作為默認渲染器運行SWT瀏覽器的最簡單示例。 並得到這個錯誤
--- exec-maven-plugin:1.2.1:exec (default-cli) @ SwtBrowser ---
Exception in thread "main" org.eclipse.swt.SWTError: XPCOM error 0x80004005
at org.eclipse.swt.browser.Mozilla.error(Unknown Source)
at org.eclipse.swt.browser.Mozilla.initXULRunner(Unknown Source)
at org.eclipse.swt.browser.Mozilla.create(Unknown Source)
at org.eclipse.swt.browser.Browser.<init>(Unknown Source)
at dev.nazm.swt.Mozilla.main(Mozilla.java:57)
------------------------------------------------------------------------
我用谷歌搜索了這個問題並得到了這些答案,但是這些都無濟於事
以及其他有關eclipse支持的鏈接。 但是沒有任何幫助
這是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.nazm</groupId>
<artifactId>SwtBrowser</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>SwtBrowser</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>maven-eclipse-repo</id>
<url>http://maven-eclipse.github.io/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${swtGroup}</groupId>
<artifactId>${swtArtifact}</artifactId>
<version>${swtVersion}</version>
</dependency>
<dependency>
<groupId>naz.dev</groupId>
<artifactId>javafx.embed.swt</artifactId>
<version>8.0.0-Final</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-invoker</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jogamp.jogl/jogl-all-main -->
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
<version>6.0.0</version>
<type>jar</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.core/org.eclipse.core.runtime -->
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.runtime</artifactId>
<version>3.7.0</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>mac</id>
<activation>
<os>
<name>Mac OS X</name>
<arch>x86_64</arch>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-XstartOnFirstThread</argument>
<argument>-classpath</argument>
<classpath/>
<argument>dev.nazm.browser.SwtBrowser</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<swtGroup>org.eclipse.swt</swtGroup>
<swtArtifact>org.eclipse.swt.cocoa.macosx.x86_64</swtArtifact>
<swtVersion>4.4</swtVersion>
</properties>
</profile>
<profile>
<id>windows10_64</id>
<activation>
<os>
<name>windows 10</name>
<family>Windows</family>
<arch>amd64</arch>
</os>
</activation>
<properties>
<swtGroup>org.eclipse.swt</swtGroup>
<swtArtifact>org.eclipse.swt.win32.win32.x86_64</swtArtifact>
<swtVersion>4.4</swtVersion>
</properties>
</profile>
<profile>
<id>windows32</id>
<activation>
<os>
<family>Windows</family>
<arch>x86</arch>
</os>
</activation>
<properties>
<swtGroup>org.eclipse.swt</swtGroup>
<swtArtifact>org.eclipse.swt.win32.win32.x86</swtArtifact>
<swtVersion>4.4</swtVersion>
<!--<classifier>debug</classifier>-->
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<configuration>
<!-- specify UTF-8, ISO-8859-1 or any other file encoding -->
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>dev.nazm.browser.SwtBrowser</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
我已經下載了xulrunner 24.0並將其解壓縮到C:\\ Program Files \\ xulrunner24。
這是我的主班
public class SwtBrowser {
public static void main(String[] args) {
String path = "C:\\Program Files\\xulrunner24";
System.getProperties().setProperty("org.eclipse.swt.browser.XULRunnerPath",path);
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.MOZILLA);
browser.setUrl("https://chromium.github.io/octane/");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
這是我的Java版本
java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)`
我正在Windows 10 amd64環境中嘗試此操作。 我已經在計算機上安裝了Mozilla FirefoxESR 24.0。 我還安裝了VisualC ++ Redistributable
現在我的問題是?
正如SWT常見問題解答所說的Windows(x86_64)要求:
必須安裝任何具有版本1.9.2.x-3.6.x,10.x或24.x的XULRunner,以及Visual C ++ 2010運行時
OS架構對xulrunner有影響嗎?
我已經安裝了eclipse neon 3,並嘗試創建一個項目並在.ini文件中添加運行時參數。 但是仍然有同樣的問題。 因此,最后一個問題是如何在Windows 64位平台上的Maven項目中運行它。
使用64位4.3 SWT(和4.4(我僅測試了這兩個)),我可以使用XULRunner 1.9.2.25版運行時來運行您的代碼。
由於64位JVM(1.8),我還必須更新pom.xml
以提取64位SWT( org.eclipse.swt.win32.win32.x86_64
而不是org.eclipse.swt.win32.win32.x86
) .0_131)。
最初,我從這里找到xulrunner下載: https : //osdn.net/projects/sfnet_runawfe/downloads/SRC%20and%20BIN%20files/extras/xulrunner-1.9.2.25-win64.zip/
但是,我還在我的存儲庫中將其重新托管為xulrunner-1.9.2.25.en-US.win64.zip
。
關於在Maven項目中執行此操作,我不確定。 您可以將其與您的應用程序一起打包在一個lib
目錄中。 如果將xulrunner運行時打包並放入Maven存儲庫中有幫助,我也可以托管它(我們可以將其托管在您擁有的存儲庫中)。
讓我知道這是否無效,我很樂意再看一遍。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.