実行した環境
ラズパイでリモートデスクトップの設定を行い、WindowsのPCからリモートデスクトップ接続にてJavaFXを起動したときのエラーメッセージです。
ラズパイでのリモートデスクトップ設定に関してはリンク先の記事に書きました。
Failed to write to /sys/class/input/mice/uevent
ラズパイで作成したコード、JavaFXを起動するアプリケーションのコードをGithubから取得して、コンパイル、JARファイルを生成、実行したときのエラーです。
dev: Failed to write to /sys/class/input/mice/uevent
Check that you have permission to access input devices
java.io.FileNotFoundException: /sys/class/input/mice/uevent (許可がありません)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
at com.sun.glass.ui.monocle.SysFS.write(SysFS.java:121)
at com.sun.glass.ui.monocle.SysFS.triggerUdevNotification(SysFS.java:108)
at com.sun.glass.ui.monocle.LinuxInputDeviceRegistry.<init>(LinuxInputDeviceRegistry.java:74)
at com.sun.glass.ui.monocle.LinuxPlatform.createInputDeviceRegistry(LinuxPlatform.java:37)
at com.sun.glass.ui.monocle.NativePlatform.getInputDeviceRegistry(NativePlatform.java:67)
at com.sun.glass.ui.monocle.MonocleApplication.<init>(MonocleApplication.java:71)
at com.sun.glass.ui.monocle.MonoclePlatformFactory.createApplication(MonoclePlatformFactory.java:42)
at com.sun.glass.ui.Application.run(Application.java:146)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:259)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
実行手順
ラズパイを起動して、以下のようなコマンドを叩きました。
cd repos # リポジトリのあるディレクトリに移動
git pull # Gitからソースを取得する
そして、Javaコマンドで作成したJARファイルを実行
これは、コマンドの実行時に、「sudo」をつけることで解決しました。
つまりは以下のようなコマンドを実行すればよいわけです。エラーの原因はファイルにアクセスする権限がなかったということです。
なので「sudo」コマンドでスーパーユーザーの権限でjavaコマンドを実行したら解決したというわけです。
sudo java -jar target/RPiMediaPlayer-0.0.1-SNAPSHOT-jar-with-dependencies.jar
次のエラーメッセージ
出力されたメッセージは下のようなものです。
Exception in Application constructor
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Unable to construct Application instance: class application.Main
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:907)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$7(LauncherImpl.java:819)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:93)
at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:52)
... 1 more
Caused by: java.awt.AWTError: Can't connect to X11 window server using ':10.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
at application.Main.initWindowInfo(Main.java:154)
at application.Main.<init>(Main.java:88)
... 12 more
Exception running application application.Main
キーポイント
ここで忘れてはいけないのが「リモートデスクトップ」での実行であったというところ
そして、以下の部分がキーポイントになりました。
Can't connect to X11 window server using ':10.0' as the value of the DISPLAY variable.
しかし、この部分の解決に至らず。。。
もう少し調査をすることにしました。
そして、調べていくうちにSSHなどのように外部からアクセスして実行するケースで上のようなエラーメッセージが表示されるという記事を見つけました。
つまりは、リモートデスクトップでのアプリケーションの起動は、エラーが出るということでした。
次は、ラズパイ本体で実行してみることにします。
でわでわ。。。