B4J Question JavaFX installation on Raspberry PI help needed

johan vetsuypens

Member
Licensed User
Longtime User
Hello,

I have installed the latest Raspbian on my raspberry PI 2 via the NOOBS OS installer v 1.7.0
https://www.raspberrypi.org/help/noobs-setup/

I have some problems with the installation part of java:

In Erel's tutoral is written :
https://www.b4x.com/android/forum/threads/b4j-and-raspberry-pi-boards.37019/#content


"If you want to run UI applications then you need to install Java 8: https://jdk8.java.net/download.html
You need to download Linux ARMv6/7 VFP, HardFP ABI."


I can't get javafx to run with B4J. I get netx error when trying to debug B4J GUI application :
Error: JavaFX runtime components are missing, and are required to run this application

my questions :
a) Do I still need to install Java 8 JDK ,because per default java 1.8.0_65 JRE is installed in this version of Raspbian .
c) Can I have an updated easy to follow instruction how to get and install JavaFX ? It seems that the Linux ARMv6/7 VFP, HardFP AB trickk in the tutorial doesn't work.

Thanks,
Johan
 

rbghongade

Active Member
Licensed User
Longtime User
Dear friend,
Here is what worked for me:
Step 1: Download http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-arm32-vfp-hflt.gz
Step 2: sudo tar zxvf jdk-8u73-linux-arm32-vfp-hflt.gz -C /opt ->installs in /opt
Step3: sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_73/bin/javac 1
Step4 :sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_73/bin/java 1
Step5: sudo update-alternatives --config javac
Step6: sudo update-alternatives --config java
Step7: download http://108.61.191.178/downloads/openjfx-8u40-sdk-overlay-linux-armv6hf.zip

Step8: sudo unzip openjfx-8u40-sdk-overlay-linux-armv6hf.zip -d /opt/jdk1.8.0_73

That should be all!
 
Last edited:
Upvote 0

johan vetsuypens

Member
Licensed User
Longtime User
Works perfectly. Thank you so much.
Just 2 minor remarks.

a) due to the 'Accept License Agreement' missing , step 1 does not work. You need to go to the main link http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html , accept the Licence Agreement, en download jdk-8u73-linux-arm32-vfp-hflt.tar.gz

b) step 3 & 4 are missing '_73' in the path : sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_73/bin/javac 1

have a nice evening,

Johan
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
Just had exactly the same problem. Went back to Wheezy but now I will upgrade again. Thanks.
 
Upvote 0

pevguitars

Member
Licensed User
Longtime User
I can get the test UI apps to display on Raspberry Pi 3 B, but the mouse and keyboard don't work.

The Pi system returns debug errors in the b4j log as follows:-

Program started.Waiting for debugger to connect...
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/mouse0/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/input3/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/input2/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/input1/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/input0/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/event3/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/event2/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/event1/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/event0/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/mice/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/js0/uevent

As a total novice with B4J I would appreciate any help..

Footnote.. As a guitar builder I have made a couple of guitar testing applications for Android tablets and phones using B4A. Very happy with the results. Thanks Erel for providing a fantastic suite of programming applications..

Peter V
 
Last edited:
Upvote 0

pevguitars

Member
Licensed User
Longtime User
Thank you.. that solved it.. works perfectly...

Here is my command line:
B4X:
sudo /usr/bin/java -jar b4j/b4j-bridge.jar
Peter V
 
Last edited:
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Thank you.. that solved it.. works perfectly...

Could you post your experiences with a ui-app and maybe a description what kind of app it is? (used views, etc.) There are reports that the ui is slow (whatever that exactly means). Thank's in advance.
 
Upvote 0

pevguitars

Member
Licensed User
Longtime User
I have only used some simple test examples so far.

I have not done enough with it yet to give you a decent answer..
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
There are reports that the ui is slow

I have an app which uses 6 labels, 2 imageviews and a button. The UI is slow to start but once running it is okay. The rest of the app is bluetooth and serial data transfer. That works in second takt. The app is controlled via a B4A app using bluetooth.
 
Upvote 0

pevguitars

Member
Licensed User
Longtime User
I have made an app to design guitar outlines using a cubic spline calculation. The spline is drawn on a canvas and can be dragged to any shape with an adjustable number of control points. In a Pi 3 it works perfectly with no perceptible delay on re-draws.

As yet I don't have the output printing working.. I have another thread on this.
 
Upvote 0

stefanogoria

Member
Licensed User
Longtime User
I can get the test UI apps to display on Raspberry Pi 3 B, but the mouse and keyboard don't work.

The Pi system returns debug errors in the b4j log as follows:-

Program started.Waiting for debugger to connect...
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/mouse0/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/input3/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/input2/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/input1/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/input0/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/event3/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/event2/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/event1/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/event0/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/mice/uevent
Check that you have permission to access input devicesUdev: Failed to write to /sys/class/input/js0/uevent

As a total novice with B4J I would appreciate any help..

Footnote.. As a guitar builder I have made a couple of guitar testing applications for Android tablets and phones using B4A. Very happy with the results. Thanks Erel for providing a fantastic suite of programming applications..

Peter V

Run it with sudo and it works perectly.
The only problem I found is on webview

This is the debug error
Java HotSpot(TM) Client VM warning: You have loaded library /opt/jdk1.8.0_73/jre/lib/arm/libjfxwebkit.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.

Any suggestion ?
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Dear friend,
Here is what worked for me:
Step 1: Download http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-arm32-vfp-hflt.gz
Step 2: sudo tar zxvf jdk-8u73-linux-arm32-vfp-hflt.gz -C /opt ->installs in /opt
Step3: sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_73/bin/javac 1
Step4 :sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_73/bin/java 1
Step5: sudo update-alternatives --config javac
Step6: sudo update-alternatives --config java
Step7: download http://108.61.191.178/downloads/openjfx-8u40-sdk-overlay-linux-armv6hf.zip

Step8: sudo unzip openjfx-8u40-sdk-overlay-linux-armv6hf.zip -d /opt/jdk1.8.0_73

That should be all!
Thanks a lot.
I would add to pay attention to the Step5 & 6. Make sure you choose the option that point to /opt/jdk1.8.0_73...... folder
This will make sure you're using the correct version of the Java package.
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

My java is 8u101, java fx is 8u60. My app have webview. It run in wins7 OK but debian always give me following message, Why...

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private we,temp As JavaObject 
    Private startPage As String = "http://192.168.1.168:8001"
    Private doc As JavaObject        ' JavaObject library
    Private js As jScriptEngine     ' jScriptEngine library
    Private WebView1 As WebView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    MainForm.rootPane.LoadLayout("main1") 'Load the layout file.
    temp = WebView1
    we = temp.RunMethod("getEngine",Null)
    WebView1.Enabled = True
    WebView1.Visible = True
    we.RunMethod("load",Array As Object(startPage))
    MainForm.Show
End Sub

B4X:
Waiting for debugger to connect...
Program started.
Java HotSpot(TM) Client VM warning:
You have loaded library /opt/jdk1.8.0_101/jre/lib/arm/libjfxwebkit.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
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 anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:16)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:118)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:168)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:79)
    at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:81)
    at b4j.example.main._appstart(main.java:80)
    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 anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
    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.lan
g.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.start(main.java:36)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
    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:92)
    at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAc
cessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at anywheresoftware.b4j.objects.NodeWrapper.buildNativeView(NodeWrapper.java:668)
    at anywheresoftware.b4j.objects.WebViewWrapper.build(WebViewWrapper.java:92)
    ... 33 more
Caused by: java.lang.UnsatisfiedLinkError: /opt/jdk1.8.0_101/jre/lib/arm/libjfxwebkit.so: /opt/jdk1.8.0_101/jre/lib/arm/libjfxwebkit.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoader.java:201)
    at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:94)
    at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:39)
    at com.sun.webkit.WebPage.lambda$static$0(WebPage.java:130)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.webkit.WebPage.<clinit>(WebPage.java:129)
    at javafx.scene.web.WebEngine.<init>(WebEngine.java:858)
    at javafx.scene.web.WebEngine.<init>(WebEngine.java:845)
    at javafx.scene.web.WebView.<init>(WebView.java:271)
    ... 39 more
Error occurred on line: 19 (Main)
java.lang.RuntimeException: Object should first be initialized (WebView).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32)
    at anywheresoftware.b4j.objects.NodeWrapper.innerInitialize(NodeWrapper.java:83)
    at anywheresoftware.b4j.objects.WebViewWrapper.innerInitialize(WebViewWrapper.java:33)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:150)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:168)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:79)
    at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:81)
    at b4j.example.main._appstart(main.java:80)
    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 anywheresoftware.b4a.shell.She
ll.runMethod(Shell.java:612)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
    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 anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.start(main.java:36)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
    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.PlatformImp
l.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
    at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
    at java.lang.Thread.run(Thread.java:745)
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Are you running it on a Raspberry Pi?
1. Yes,I am running in Raspbery PI2/jessie.
2. Do i need install X Window and Desktop/GNome first ?
3. This App will be a HMI. It as a Web Browser and connect WebSocket Server directly.
 
Upvote 0

nakwada

New Member
Hi guys,

Is there anyway to do the same under Arch Linux ARM ?
Got a project to run on this platform and am stuck because of OpenJDK lacking JFX stuff.

Thanks !
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

Why does debugger give me following message when i running ui-app ?

main.start (java line: 37)
java.lang.ExceptionInInitializerError
at javafx.scene.Node.reapplyCss(Node.java:8962)
at javafx.scene.Node.impl_reapplyCSS(Node.java:8925)
at javafx.scene.Node.invalidatedScenes(Node.java:833)
at javafx.scene.Node.setScenes(Node.java:898)
at javafx.scene.Scene$9.invalidated(Scene.java:1119)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
at javafx.scene.Scene.setRoot(Scene.java:1072)
at javafx.scene.Scene.<init>(Scene.java:347)
at javafx.scene.Scene.<init>(Scene.java:223)
at anywheresoftware.b4j.objects.Form.shared(Form.java:59)
at anywheresoftware.b4j.objects.Form.initWithStage(Form.java:48)
at b4j.example.main.start(main.java:37)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImp
l.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at com.sun.javafx.font.PrismFontLoader.loadFont(PrismFontLoader.java:196)
at javafx.scene.text.Font.<init>(Font.java:319)
at javafx.scene.text.Font.getDefault(Font.java:86)
at javafx.scene.CssStyleHelper.<clinit>(CssStyleHelper.java:1528)
... 21 more
 
Upvote 0
Top