Hello everyone
I need remotely to have a simple screen replication of a raspberry LCD, the connection between server (Raspy) and client (Pc) is done with mqtt protocol.
If I use it (server) on desktops (win10) everything works perfectly but on the raspberry I fail in the following lines of code:
This is the frame capture part
I have two possibilities one complete that also shows notifications and everything overlapping on the main, the other just the main.
Capture only Main:
It doesn't load the swing class?
'
Capture All:
Error when loading awt class?
How can I fix this?
Thanks
Foreword
I do not boot x windows on raspberry, my program starts it in console mode automatically with the following line in crontab:
I need remotely to have a simple screen replication of a raspberry LCD, the connection between server (Raspy) and client (Pc) is done with mqtt protocol.
If I use it (server) on desktops (win10) everything works perfectly but on the raspberry I fail in the following lines of code:
This is the frame capture part
I have two possibilities one complete that also shows notifications and everything overlapping on the main, the other just the main.
Capture only Main:
B4X:
Sub CatturaImg
Dim out As OutputStream
out.InitializeToBytesArray(0)
Dim img As Image = Main.MainForm.RootPane.Snapshot
If img.IsInitialized = False Then Return
img.WriteToStream(out) '<----------Error'
out.Close
Dim cc As CompressedStreams
SendFrame(cc.CompressBytes(out.ToBytesArray,"zlib").As(Object))
End Sub
Error:
Connected mqtt
mqttserv._catturaimg (java line: 63)
java.lang.NoClassDefFoundError: javafx/embed/swing/SwingFXUtils
at anywheresoftware.b4j.objects.ImageViewWrapper$ImageWrapper.WriteToStream(ImageViewWrapper.java:199)
at b4j.SepPi.mqttserv._catturaimg(mqttserv.java:63)
at b4j.SepPi.mqttserv.callSub(mqttserv.java:356)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:498)
at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:461)
at b4j.SeparatorePi.mqttserv._timer1_tick(mqttserv.java:349)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:135)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
at javafx.graphics/com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: javafx.embed.swing.SwingFXUtils
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 18 more
'
Capture All:
B4X:
Sub CatturaImg
Dim awt As AWTRobot
awt.ScreenCurrentRectangleSetAsArbitrary(Main.MainForm.WindowLeft,Main.MainForm.WindowTop,Main.MainForm.WindowWidth,Main.MainForm.WindowHeight)
Dim cc As CompressedStreams
SendFrame(cc.CompressBytes(awt.ScreenCaptureAsByteArray,"zlib").As(Object))
End Sub
Error:
Connected mqtt
java.awt.AWTException: headless environment
at java.desktop/java.awt.Robot.<init>(Robot.java:94)
at butt.droid.awtRobot.AWTRobot.<init>(AWTRobot.java:91)
at b4j.SepPi.mqttserv._catturaimg(mqttserv.java:72)
at b4j.SepPi.mqttserv.callSub(mqttserv.java:356)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:498)
at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:461)
at b4j.SeparatorePi.mqttserv._timer1_tick(mqttserv.java:349)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:135)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
at javafx.graphics/com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
at java.base/java.lang.Thread.run(Thread.java:834)
mqttserv._timer1_tick (java line: 349)
java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:523)
at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:461)
at b4j.SeparatorePi.mqttserv._timer1_tick(mqttserv.java:349)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:135)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
at javafx.graphics/com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
at butt.droid.awtRobot.AWTRobot.ScreenCaptureAsByteArray(AWTRobot.java:858)
at b4j.SepPi.mqttserv._catturaimg(mqttserv.java:78)
at b4j.SepPi.mqttserv.callSub(mqttserv.java:356)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:498)
... 14 more
How can I fix this?
Thanks
Foreword
I do not boot x windows on raspberry, my program starts it in console mode automatically with the following line in crontab:
B4X:
@reboot sudo /usr/lib/jvm/jdk-11.0.1/bin/java -jar /home/pi/Xxxxx/Xxxxx.jar
Last edited: