【发布时间】:2017-10-08 23:18:39
【问题描述】:
我正在尝试以 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)
------------------------------------------------------------------------
我搜索了这个问题并得到了这些答案,但这些都没有任何帮助
Creating a SWT.MOZILLA browser on Windows 64 bit and SWT 4.3
How to make SWT Browser control use mozilla instead of IE on Windows
还有一些关于 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
现在我的问题是?
- 我的电脑上安装的 Firefox 版本是否需要满足 xulrunner 的版本。
-
正如 SWT FAQ 所说的 Windows (x86_64) 的要求:
具有 1.9.2.x - 3.6.x、10.x 或 24.x 版本的任何 XULRunner 版本,以及 必须安装 Visual C++ 2010 运行时
操作系统架构对 xulrunner 重要吗?
我已经安装了 eclipse neon 3,并尝试创建一个项目并在 .ini 文件中添加运行时参数。但仍然遇到同样的问题。所以最后一个问题是如何在 Windows 64 位平台上的 maven 项目中运行它。
【问题讨论】: