B4J Tutorial B4J and Raspberry Pi boards

Mark Turney

Active Member
Licensed User
Longtime User
Same one I ordered Erel ... nice for just a little more money comes with the extra .
 

Bob Coleman

New Member
Licensed User
Longtime User
You won't want to bother with the heatsink in the kit as they can get in the way of HATs and are unneeded except when abusing the PI when overclocking.

So that kit will get you what you need and then some.
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User

I just got a RPi board in to play with and I'm trying to make simple "Hello Word" GUI show up.

I've followed the above-quoted instructions (using the latest version at the link, 1.8.0u76) and when I run a test program, it's complaining that the JavaFX runtime components are missing. I've tried it with and without the "#MergeLibraries: True" project attribute.

Did I miss a step, or is there some project attribute that I am failing to set?

Thanks in advance!
 
Last edited:

Mark Turney

Active Member
Licensed User
Longtime User
Without seeing the code, it sounds like perhaps the JavaFx version for the RPi is wrong. I am typing this in my car on the phone so I don't have access to my Mac right now, but do a search for JavaFx version support and ARM processors.

Hope this helps!
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Thank you, Mark, that was the right direction. I misunderstood that the new Java version does not contain JavaFX (I incorrectly assumed it was now built-in as there is no longer a separate download link with the JDK downloads).

I downloaded and installed a user-built version of JavaFX from here: http://108.61.191.178/ (there are instructions for unzipping it there, just make sure the path you use is the same one you used in Earl's step in post #1).

After doing that, I can see a full-screen version of the app window now, the buttons do not look correct but that is probably something I can overcome via some specific CSS entries.

Thank you for the direction!
 

Mark Turney

Active Member
Licensed User
Longtime User
You're very welcome. I'm glad I could help. Enjoy the Raspberry Pi too ... It's got so much potential and is a load of fun to boot !
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
It is a lot of fun! The Linux experience harkens back to the MS DOS 3.x-6.x days of my misspent youth.

Also, as a side note, the problem with the buttons was a lack of video memory, once I increased the video memory to 128MB (raspi-config -> Advanced Options -> Memory Split) the buttons displayed were the same as my virtual Debian box and my Windows machine.
 

micro

Well-Known Member
Licensed User
Longtime User
I downloaded and installed a user-built version of JavaFX from here: http://108.61.191.178/ (there are instructions for unzipping it there, just make sure the path you use is the same one you used in Earl's step in post #1).

Hi
Is this the file used? OpenJFX 8u40 stable for armv6hf
Time ago I installed openJFX and work on raspberry but not completely
In the Textfield if I click on the keyboard is not written anything.
The rest works
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
That seems to be the same download link as I used. I was experiencing random GUI issues with my test program until I increased the video memory. If you haven't done that yet I'd try that and see if your textfield operates properly.
 

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi Erel,
I'm not an expert in Java or B4J, but before writing to you have tried any possible combination of test, reading back and forth from the forum.
I'm facing a problem using the WebView in a very simple UI application.
I've seen that JavaFX is no more supported, but this mean that B4J never ever can support UI applications?

All I want to just test (if possible, then) is to put a WebView into a Form, and load a page.
But seems it is impossible to get this result.
I'm using Raspberry using NOOBS.
I've installed JAVA using this file from Oracle: jdk-8-linux-arm-vfp-hflt.tar.gz
I've also installed the JavaFX from this file: openjfx-8-sdk-overlay-linux-armv6hf.zip
I've installed JAVA into the folder /home/pi/jdk1.8.0


I've also installed different version of JAVA from: jdk-8u60-linux-arm32-vfp-hflt.tar.gz
and installed the JavaFX from this file: openjfx-8u60-sdk-overlay-linux-armv6hf.zip
I've installed JAVA into the folder /home/pi/jdk1.8.0_60

Both the "openjfx" files was expanded into the respective folders (jdk1.8.0 and jdk1.8.0_60)

If I set the system to use the jdk from the jdk1.8.0 folder, I get this result:


java.lang.ClassNotFoundException: com.sun.glass.ui.monocle.MonoclePlatformFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:45)
at com.sun.glass.ui.Application.run(Application.java:145)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:279)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:216)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:653)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:314)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:305)
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:483)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Failed to load Glass factory class
Exception 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:483)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.NullPointerException
at com.sun.glass.ui.Application.run(Application.java:145)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:279)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:216)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:653)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:314)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:305)
... 5 more


If I set the system to use the jdk from jdk1.8.0_60 I get this result:

Waiting for debugger to connect...
Program started.
Java HotSpot(TM) Client VM warning: You have loaded library /home/pi/jdk1.8.0_60/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:497)
at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:16)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:116)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:166)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:78)
at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:81)
at b4j.example.main._appstart(main.java:83)
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:497)
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.lang.reflect.Method.invoke(Method.java:497)
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.s
un.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.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at anywheresoftware.b4j.objects.NodeWrapper.buildNativeView(NodeWrapper.java:664)
at anywheresoftware.b4j.objects.WebViewWrapper.build(WebViewWrapper.java:92)
... 33 more
Caused by: java.lang.Unsatisf
iedLinkError: /home/pi/jdk1.8.0_60/jre/lib/arm/libjfxwebkit.so: /home/pi/jdk1.8.0_60/jre/lib/arm/libjfxwebkit.so: classe ELF errata: ELFCLASS64 (Possible cause: architecture word width mismatch)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
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: 26 (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:148)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:166)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:78)
at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:81)
at b4j.example.main._appstart(main.java:83)
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:497)
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:497)
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)


I'm using B4J v4.20(1)
I've followed all the instructions given at this post: https://www.b4x.com/android/forum/t...n-raspberry-pi-help-needed.63403/#post-400773
but the result is the same as the second above.

It is possible to have a detailed list with all the steps to follow, in order to have a JavaFX fully working?
I'm doing something wrong but really do not understand now where. Please could you help?

In attachment is the zipped test project.

Thank you for your support.

Best regards,
Michele.
 

Attachments

  • WebView UI Test Application.zip
    2.2 KB · Views: 491

tango

Member
Licensed User
Longtime User
can we play a video in raspberry pi in a application?
i want to play a video but UI apps will run in a full screen mode. and MediaPlayer is also not supported.
is there any way to play a video in UI apps.? how?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…