为什么使用OpenJDK+openjfx的JavaFX应用程序在Ubuntu 16上失败



我已经创建了一个非常基本的JavaFX应用程序

// Viewer.java
package crossjavafx;
public class Viewer {
public static void main(String[] args) {
MainViewer.main(args);
}
}
// MainViewer.java
package crossjavafx;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MainViewer extends Application {
@Override
public void start(Stage stage) {
try {
System.out.println("Hello from Viewer");
Group root = new Group();
Scene scene = new Scene(root, 400, 300);
stage.setTitle("Hello");
stage.setScene(scene);
stage.show();
} catch (final Exception e) {
System.exit(1);
}
}
public static void main(String args[]){
launch(args);
}
}

还有一个简单的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>crossjavafx</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

我已经在Ubuntu 16.04上使用mvn和:构建了它

./java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~16.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

我还安装了openjfx和libopenjfx软件包:

libopenjfx-java/xenial,xenial,now 8u60-b27-4 all [installed]
libopenjfx-jni/xenial,now 8u60-b27-4 amd64 [installed,automatic]
openjfx/xenial,now 8u60-b27-4 amd64 [installed]

应用程序已成功生成,但未能启动。在打印"Hello from Viewer"之前,进程将挂起。我启动它:

/usr/lib/jvm/java-8-openjdk-amd64/bin/java -cp crossjavafx-0.1.0-SNAPSHOT.jar crossjavafx.Viewer

以同样的方式启动非javafx应用程序构建,即使从同一个JAR调用其类,我也没有问题,所以我认为我的javafx安装有问题。

我还尝试使用Java8OracleSDK构建和运行它,得到了相同的结果。我的JavaFX安装中有没有遗漏的东西,我忘记了?

编辑

我已经构建并尝试使用Java8Oracle运行它,打印stacktrace。我得到了:

Hello from Viewer
Framebuffer object format is unsupported by the video hardware. (GL_FRAMEBUFFER_UNSUPPORTED)(FBO - 820)
Error creating framebuffer object with TexID 1)
[VGL] ERROR: OpenGL error 0x0502
[VGL] ERROR: in readPixels--
[VGL]    475: Could not Read Pixels

我遇到了类似的问题,并添加了以下参数作为VM参数"-Djavafx.platform=monocle-Dmonocle.platform=C11-Dembedded=monocle"。当我使用eclipse时,我将其添加到Run configuration Run->Run configuration。。。在eclipse 中运行配置

我在https://wiki.openjdk.java.net/display/OpenJFX/Building++OpenJFX+嵌入式+堆栈+for+Linux+桌面

相关内容

最新更新