B4J Question Raspberry Pi - Smiley example not working

David Riley

Member
Licensed User
Longtime User
The face bounces around. But when I click on Files nothing happens.
On the pc it lets me pick a destination and saves the image.

Trying to run "Canvas1.Snapshot.WriteToStream(Out)" gives long error report starting:

"java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/embed/swing/SwingFXUtils
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)"

Should I have included SwingFXUtils somewhere ?
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

For Raspberry Pi at present Media and Web modules are NOT included (=supported).
This is a recent statement from the Oracle Java Development Team related to the Java 8 ARM version:

... we have not removed anything from JDK 8 that would cause it to be labeled a "lite" version. There are some components that are not part of the Java SE 8 specification but rather optional add-ons, such as JavaDB and (yes) JavaFX. Until a component is part of the spec - which is a longer process - changes to it are to be expected.

For JavaFX specifically, this is still very much under development. We started on desktops (Windows/Mac/Linux, x86) and are adding support for Linux/ARM now. The Linux/ARM work we do is primarily intended for smaller embedded devices, not fully functional desktops, and our development priorities are set accordingly - media/web not done at this point for instance. However, not that JavaFX is completely open source through the OpenJFX project so if you have the interested, skill and time on your hands you can fill this gap yourself!
...

BTW: Have tested also recently a B4J UI app on a Raspberry Pi - See here, select Category Raspi Item Build a B4J UI App with some hints.
 
Upvote 0

David Riley

Member
Licensed User
Longtime User
Hi Rob,

I'm completely new to Java and Linux. So I don't have much skill to do things myself.
My best source of information has been your website. Thanks very much.
I've been able to get UI apps to work. But the saving of graphics to file failed when run on Raspberry Pi.
Is there possibly an optional add-on to do this ?

David
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi David,

have not tried - will look into next week.

Thanks for the feedback regarding my website.
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
(Reply Post #7)
A rather late answer, but thought I share a solution as building a JavaFX Dashboard running on a Raspberry Pi 3 Model B+ (RPi).
The dashboard is part of a Home Automation solution in progress.
Started developing the dashboard step-by-step and one feature is to make a screenshot of the dashboard when running on the RPi.

Create Screenshot
Example creating a screenshot of the main form when the application runs in full screen on a Raspberry Pi.
Tested on a RPi 3 Model B+ running Stretch, jdk1.8.0_162, Gluon JavaFXPorts armv6hf-sdk-8.60.9.

Requirements
B4X:
 #Region Project Attributes
   #MainFormWidth: 600
   #MainFormHeight: 600
   'The jar jfxrt is required for the class SwingFXUtils to make a screenshot of the mainform when running on the RPi.
   'This to avoid runtime error: java.lang.NoClassDefFoundError: javafx/embed/swing/SwingFXUtils
   'Copy c:\Program Files (x86)\Java\jdk8\jre\lib\ext\jfxrt.jar to the B4J additional libraries folder.
   'Note: Check your JDK path prior copying to the B4J additional library folder.
   #AdditionalJar: jfxrt
   #MergeLibraries: True
 #End Region

Example sub make a snapshot of the mainform
B4X:
Sub FormSnapShot
   Dim img As Image = MainForm.RootPane.Snapshot
   Dim Out As OutputStream = File.OpenOutput(File.DirApp, "rpicputemperaturedashboard.png", False)
   img.WriteToStream(Out)
   Out.Close
End Sub

Notes
When running via the B4J-Bridge, the screenshot is stored in the tempjars folder.

Example Dashboard Raspberry Pi CPU Temperature (measured every 5 seconds)
upload_2018-3-28_11-20-48.png


The B4J source attached - the CPU Temperature is measured using resumable sub, the gauge properties are set using API method via a JavaObject.
 

Attachments

  • rpicputemperaturedashboard.zip
    4.5 KB · Views: 221
Upvote 0
Top