创建简单的javafx 11“ hello world”应用程序。创建自定义JRE时出错。
user@user:~/Desktop/javafx/hellofx$ ./run.sh
Error: Hash of java.xml (c043b4c28b897656e2a4d36c92ba2f5d52134bce79643236dd36295e14178be7) differs to expected hash (4e7db7fc941d9f316c4aafe02717b5809ee722be8433d283050365e7fd49331f) recorded in java.base
错误代码:
$JAVA_HOME/bin/jlink --module-path $PATH_TO_FX_MODS:mods --add-modules hellofx --output hellofx #error
OS:ubuntu 19.10
$ java --versionopenjdk 11.0.6 2020-01-14OpenJDK运行时环境(内部版本11.0.6 + 10-post-Ubuntu-1ubuntu119.10.1)OpenJDK 64位服务器VM(内部版本11.0.6 + 10-post-Ubuntu-1ubuntu119.10.1,混合模式,共享)
$ javac --versionjavac 11.0.6
user@user:~/Desktop/javafx/hellofx$ tree
.
├── mods
│ └── hellofx
│ ├── hellofx
│ │ └── HelloFX.class
│ └── module-info.class
├── run.sh
└── src
├── hellofx
│ └── HelloFX.java
└── module-info.java
5 directories, 5 files
run.sh:
user@user:~/Desktop/javafx/hellofx$ cat run.sh
export PATH_TO_FX=/home/sameep/javafx-sdk-11.0.2/lib
export PATH_TO_FX_MODS=/home/sameep/javafx-jmods-11.0.2
javac --module-path $PATH_TO_FX -d mods/hellofx $(find src -name "*.java")
java --module-path $PATH_TO_FX:mods -m hellofx/hellofx.HelloFX
$JAVA_HOME/bin/jlink --module-path $PATH_TO_FX_MODS:mods --add-modules hellofx --output hellofx #error
#hellofx/bin/java -m hellofx/hellofx.HelloFX
module-info.java:
user@user:~/Desktop/javafx/hellofx/src$ cat module-info.java
module hellofx {
requires javafx.controls;
exports hellofx;
}
HelloFX.java:
user@user:~/Desktop/javafx/hellofx/src/hellofx$ cat HelloFX.java
package hellofx;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class HelloFX extends Application {
@Override
public void start(Stage stage) {
String javaVersion = System.getProperty("java.version");
String javafxVersion = System.getProperty("javafx.version");
Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
Scene scene = new Scene(new StackPane(l), 640, 480);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
您可以在链接中关注,这很可能是JDK构建问题,并且会恢复为较早的java.version
,例如11.0.2应该解决此问题。
您可以同时在openjdk-build/issues/1214上跟踪进度以进行进一步的更新。