B4J Question [SOLVED]Unable to run B4J compiled jar on Raspberry Pi 5...

rbghongade

Well-Known Member
Licensed User
Longtime User
Dear friends,
Let me first describe the hardware:
Raspberry Pi 5 on bookworm Raspbian OS
Steps I followed and subsequent logs:
Steps followed and logs:
1)Downloaded openjfx-17.0.2_linux-aarch64_bin-sdk.zip
2)Renamed it to javafx-sdk-17.0.2.zip ---> (for convenience)
3)sudo apt install openjdk-17-jdk
4)sudo mkdir -p /opt/javafx
5)sudo unzip javafx-sdk-17.0.2.zip -d /opt/javafx
6)sudo ln -s /opt/javafx/lib/javafx-sdk-17.0.2/lib/javafx-modules/ /usr/lib/jvm/java-17-openjdk-amd
7)export JAVA_MODULES_PATH=/usr/lib/jvm/java-17-openjdk-amd64/lib/javafx-
8)export PATH_TO_FX=/opt/javafx-sdk-17.0.2/lib
9)sudo java --module-path  $PATH_TO_FX --add-modules javafx.controls -jar MY_PROGRAM.jar
Logs:

rbg@rpi:~/Downloads $ sudo java --module-path $PATH_TO_FX --add-modules=javafx.controls -jar MY_PROGRAM.jar
main._appstart (java line: 115)
java.lang.RuntimeException: java.lang.IllegalAccessError: class anywheresoftware.b4a.objects.B4XCanvas$B4XPath (in unnamed module @0xacf0dc5) cannot access class com.sun.javafx.geom.Path2D (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.geom to unnamed module @0xacf0dc5
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:140)
    at anywheresoftware.b4j.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:85)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:109)
    at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:101)
    at b4j.example.main._appstart(main.java:115)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.start(main.java:37)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:290)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.IllegalAccessError: class anywheresoftware.b4a.objects.B4XCanvas$B4XPath (in unnamed module @0xacf0dc5) cannot access class com.sun.javafx.geom.Path2D (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.geom to unnamed module @0xacf0dc5
    at anywheresoftware.b4a.objects.B4XCanvas$B4XPath.InitializeRoundedRect(B4XCanvas.java:381)
    at b4j.example.swiftbutton._draw(swiftbutton.java:165)
    at b4j.example.swiftbutton._base_resize(swiftbutton.java:64)
    at b4j.example.swiftbutton._designercreateview(swiftbutton.java:143)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    ... 20 more

I have tried for about 2 days but with no success. I am not good at using linux commands. Any help is highly appreciated.
P.S: I have used jdk-19.0.2 which is recommended for B4J, for compiling the jar file.
 

rbghongade

Well-Known Member
Licensed User
Longtime User
Maybe you need some extra arguments...
Now I get:
B4X:
rbg@rpi:~/Downloads $ java -Dprism.verbose=true -Dprism.forceGPU=true -jar --module-path $PATH_TO_JAVAFX --add-modules javafx.controls, javafx.graphics MY_PROGRAM.jar
Error: Unable to access jarfile javafx.graphics
 
Upvote 0

PaulMeuris

Well-Known Member
Licensed User
arguments are separated by a space... javafx.controls, javafx.graphics ... there should not be a space behind the comma!
Sorry, i copied the line with a space after the comma.
 
Last edited:
Upvote 0

rbghongade

Well-Known Member
Licensed User
Longtime User
In my example i am using the environment variable $PATH_TO_JAVAFX and in your example you are using $PATH_TO_FX.
Adjust accordingly...
Dear Paul, indeed my bad. Let me try again with corrected command! Will update on Monday, as I will out of station till then. Thanks for your time and expertise!
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
I have tried for about 2 days but with no success. I am not good at using linux commands. Any help is highly appreciated.
P.S: I have used jdk-19.0.2 which is recommended for B4J, for compiling the jar file.

I suggest you dump the previous method that did not work, start off with a clean OS and follow this procedure:


Very simple installation and so far it has worked with a variety of Linux Distros including RPI5 -
 
Last edited:
Upvote 0

rbghongade

Well-Known Member
Licensed User
Longtime User
Dear friends, Thank you for your suggestions .
I tried all the above suggestions and with this command was able to execute the program!
B4X:
java -jar --module-path /usr/share/openjfx/lib --add-modules javafx.controls,javafx.graphics --add-exports javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene.canvas=ALL-UNNAMED MY_PROGRAM.jar
But still unable to use b4j-bridge.
 
Last edited:
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
Dear friends, Thank you for your suggestions .
I tried all the above suggestions and with this command was able to execute the program!
B4X:
java -jar --module-path /usr/share/openjfx/lib --add-modules javafx.controls,javafx.graphics --add-exports javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene.canvas=ALL-UNNAMED MY_PROGRAM.jar
But still unable to use b4j-bridge.

I really recommend you follow the instructions in my Post #7 above. I can confirm that it works with all Raspberry Pi models and OSs that we have tested so far, including RPI5 - Here is an example of a B4J Jar running on RPI5 with Raspian OS:

1744038367225.png
 
Last edited:
Upvote 0
Top