ScalaFXで作成したアプリケーションが実行できない
スポンサーリンク
環境
- Fedora27 (Docker) on ArchLinux
- Intellij IDEA 2018.1.5
- Scala 2.12.4
- Java8
- OpenJDK 1.8.0_171-b10
- OracleJDK 1.8.0_172-b11
エラー内容
Graphics Device initialization failed for : es2, sw Error initializing QuantumRenderer: no suitable pipeline found java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280) at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:221) at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:248) at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:209) at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675) at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94) at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124) ... 1 more Exception in thread "main" java.lang.RuntimeException: No toolkit found at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260) at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:209) at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675) at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:748)
調べてみる
下記はOracleJDK 1.8.0_172-b11
で実行した。
java - JavaFX on Linux is showing a "Graphics Device initialization failed for : es2, sw" - Stack Overflow
の通りに-Dprism.verbose=true
をつけて実行してみる
RUN -> RUN... -> Edit Configuration
のVM options
に-Dprism.verbose=true
を追加して実行する
Prism pipeline init order: es2 sw Using java-based Pisces rasterizer Using dirty region optimizations Not using texture mask for primitives Not forcing power of 2 sizes for textures Using hardware CLAMP_TO_ZERO mode Opting in for HiDPI pixel scaling Prism pipeline name = com.sun.prism.es2.ES2Pipeline Loading ES2 native library ... prism_es2 GraphicsPipeline.createPipeline failed for com.sun.prism.es2.ES2Pipeline java.lang.UnsatisfiedLinkError: /usr/java/jdk1.8.0_172-amd64/jre/lib/amd64/libprism_es2.so: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) (省略)
libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
ということなので
$ dnf -y install gtk2
次は、libXxf86vm.so.1: cannot open shared object file: No such file or directory
なので
$ dnf -y install libXxf86vm
次は、libGL.so.1: cannot open shared object file: No such file
なので
$ dnf -y install mesa-libGL
再度実行してみると下記のエラーが出た
libGL error: unable to load driver: swrast_dri.so libGL error: failed to load driver: swrast Prism ES2 Error - nInitialize: glXChooseFBConfig failed (X) Got class = class com.sun.prism.es2.ES2Pipeline GraphicsPipeline.createPipeline: error initializing pipeline com.sun.prism.es2.ES2Pipeline *** Fallback to Prism SW pipeline Prism pipeline name = com.sun.prism.sw.SWPipeline (X) Got class = class com.sun.prism.sw.SWPipeline Initialized prism pipeline: com.sun.prism.sw.SWPipeline vsync: true vpipe: false Error: JavaFX detected no fonts! Please refer to release notes for proper font configuration Exception in Application start method (省略)
Fallback to Prism SW pipeline
なのでlibGL error
はとりあえず無視する。Error: JavaFX detected no fonts! Please refer to release notes for proper font configuration
は下記ページをみるとTrueTypeフォントが無いのが原因らしい
TrueTypeフォントを探して入れる
$ dnf -y search fonts | grep TrueType | grep Japanese sazanami-fonts-common.noarch : Common files for Sazanami Japanese TrueType fonts motoya-lcedar-fonts.noarch : Japanese Gothic-typeface TrueType fonts by MOTOYA motoya-lmaru-fonts.noarch : Japanese Round Gothic-typeface TrueType fonts by hanazono-fonts.noarch : Japanese Mincho-typeface TrueType font vlgothic-fonts.noarch : Japanese TrueType font vlgothic-p-fonts.noarch : Proportional Japanese TrueType font sazanami-gothic-fonts.noarch : Sazanami Gothic Japanese TrueType font sazanami-mincho-fonts.noarch : Sazanami Mincho Japanese TrueType font $ dnf -y install vlgothic-fonts
ここで実行すると、下記のエラーが出たがとりあえず動くようになった。
libGL error: unable to load driver: swrast_dri.so libGL error: failed to load driver: swrast Prism ES2 Error - nInitialize: glXChooseFBConfig failed GraphicsPipeline.createPipeline: error initializing pipeline com.sun.prism.es2.ES2Pipeline *** Fallback to Prism SW pipeline (省略) vsync: true vpipe: false QuantumRenderer: shutdown
解決方法まとめ
$ dnf -y install gtk2 libXxf86vm mesa-libGL vlgothic-fonts
しておけばOpenJDKでもOracleJDKでも動いた。
ただしOpenJDKの場合は、下記のOpenJFX関連の設定が必要だった
$ dnf -y install java-1.8.0-openjdk-openjfx-devel $ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/jvm/openjfx/rt/lib/amd64 $ cp /usr/lib/jvm/openjfx/rt/lib/ext/jfxrt.jar <プロジェクトルート>/lib/