无法在Raspberrypi中使用crontab在启动时启动gui jar

时间:2019-07-09 13:51:24

标签: linux cron raspberry-pi raspbian

嗨,我正在尝试在Raspberry pi上运行基于jar的GUI。我可以通过直接从终端调用来运行它,即

/usr/bin/java -jar /home/pi/Downloads/GUI1.jar

我可以随时在cronttab上成功安排它 例如

28 * * * * DISPLAY=:0 /usr/bin/java -jar /home/pi/Downloads/GUI1.jar > /home/pi/Downloads/cron.log 2>&1

这也很好

当我尝试在启动时运行它时,问题开始了。我正在使用

@reboot DISPLAY=:0 /usr/bin/java -jar /home/pi/Downloads/GUI1.jar > /home/pi/Downloads/cron.log 2>&1

cron.log显示(错误)并且没有显示GUI

Invalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keyException in thread "main" 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 sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.UnsupportedOperationException: Unable to open DISPLAY
at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:68)
at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
at com.sun.glass.ui.Application.run(Application.java:146)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
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)
... 5 more

更新

我创建了一个简单的Java应用程序jar文件,其输出为“ Hello World!”。请注意,其中没有任何图形。

crontab中的代码

@reboot /usr/bin/java -jar /home/oi/Downloads/helloworld.jar > /home/pi/Downloads/cron1.log 2>&1

cron1.log说

Hello World!

0 个答案:

没有答案