B4J Question Initial Setup - B4J/B4J-Bridge/Raspberry Pi 4

pixelpop

Active Member
Licensed User
Longtime User
I just picked up the new Raspberry Pi 4 (1G) and decided to get back into the B4X environment (was using B4A years ago but haven't done anything with it in a long time). I think I followed Erel's instructions (they are somewhat spread out across several places) and here is what I have done so far:

1. Download the latest Java 11 (bellsoft-jdk11.0.4-linux-arm32-vfp-hflt-lite.tar) onto the RPi.
2. Unpack Java 11 (tar -xvf bellsoft-jdk11.0.4-linux-arm32-vfp-hflt-lite.tar). This creates a directory called jdk-11.0.4-lite.
3. Download and install B4J-Bridge (wget www.b4x.com/b4j/files/b4j-bridge.jar).
4. Run the bridge (sudo jdk-11/bin/java -jar b4j-bridge.jar).
5. Download and install B4J to my PC (Windows 10 Version 1903).
6. Start B4J and set Paths in B4J to C:\java\bin\javac.exe and C:\Program Files (x86)\Anywhere Software\B4J\Libraries.
7. Load MyFirstProgram.
8. Connect B4J-Bridge in B4J to RPi.
9. Start B4J-Bridge on RPi (sudo jdk-11.0.4-lite/bin/java -jar b4j-bridge.jar).
10. RPi responds:

pi@raspberrypi:~ $ sudo jdk-11.0.4-lite/bin/java -jar b4j-bridge.jar
B4J-Bridge v1.43
Running on Java 11+
External JavaFX not found. Searching for internal modules...
Waiting for connections (port=6790)...
My IP address is: 192.168.0.30
FTP Server started: ftp://192.168.0.30:6781
Start B4J-Bridge with -disableftp to disable.
JavaFX modules:

{after step 9 above}
Connected!


Now, the first thing that I don't see are any modules being loaded on the RPi. And when I compile and run MyFirstProgram in B4J I get the message error:--add modules=requires modules to be specified. And on the RPi I get:

Starting program
ProcessCompleted


So where have I gone astray here? Thanks for the help.
 

pixelpop

Active Member
Licensed User
Longtime User
That's some interesting info. But after about 20 hours on this, I have the 3B+ working so I'm going to stick with that.

That being said, SBC's in general will continue to gain popularity and the Raspberry Pi and Arduino will be probably lead the way. The Raspberry Pi 4 is especially appealing because it can be purchased in 1GB, 2GB and 4GB configurations. So if you can get Bridge working on the Raspberry Pi 4, I think you'll have a very popular product. In fact, I am willing to be your tester. If you get a setup that works, I will reinstall the OS on both the 3B+ and the 4 and test your setup from the ground up. When the procedure becomes stable, it should be documented, including downloads for all the pertinent apps. I would stay away from just including links because chances are that those links will direct to "latest" versions rather than tested versions.

Thanks!!
 
Last edited:
Upvote 0

pixelpop

Active Member
Licensed User
Longtime User
I may have stumbled across a pertinent issue. The GL drivers that are part of Raspbian Buster seem to be broken. If you run sudo raspi-config -> Advanced Options -> GL Driver and select Legacy (original non-GL driver), the B4J compiles correctly but nothing is displayed on the Pi (which makes sense). If you select GL (Fake KMS), that's when B4J gets either the "Dispman: Cannot open display" error or the "failed to add service - already in use?" error.

I did some Googling and found this: https://www.raspberrypi.org/forums/viewtopic.php?t=243892

It's way over my pay grade to understand anything in this link, but you might be able to glean something from it.
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
I battled with this problem for a long time and finally got it to work with the Liberica JDK:

https://bell-sw.com/pages/java-11.0.1/

sudo mkdir /opt/jdk
sudo tar -zxf bellsoft-jdk11.0.1-linux-arm32-vfp-hflt-lite.tar.gz -C /opt/jdk
sudo /opt/jdk/jdk-11.0.1/bin/java -jar YourProgram.jar

It even works with Java 8 jar files compiled on the PC with B4J so I did not have to do anything on the PC.

Good Luck.....
 
Upvote 0

pixelpop

Active Member
Licensed User
Longtime User
Amin, is this procedure for the Pi 3 B+ or the Pi 4? I have the Pi 3 B+ working but haven't had any luck with the Pi 4. If this is for the Pi 4 I'll give it a try.

Also, have you tested this with the B4X Bridge? That's where the "Dispman: Cannot open display" or "failed to add service - already in use?" errors occur.
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
I'm sorry. I should have read the thread more carefully. Yes, I got it to work on a 3 B+. And no, I'm not using the bridge. But the Pi 4 has the same/similar processor as the 3B+ and if you are using the same 32-bit version of Raspbian I don't see why it should make a difference. Does it work when you just copy over the JAR and run it instead of using the bridge?

Also, have you tried using Java 8 with the JavaFX overlay? I had success with this and can even run GUI applications on the Pi Zero (need to increase GPU memory to 128 or more). And I believe I got it to work with the bridge.

[optional] sudo apt update
[optional] sudo apt install raspberrypi-ui-mods
sudo unzip openjfx-8-sdk-overlay-linux-armv6hf-libbrcm-fix.zip -d /opt/jdk/jdk1.8.0_212
sudo /opt/jdk/jdk1.8.0_212/bin/java -jar YourProgram.jar
 
Upvote 0

pixelpop

Active Member
Licensed User
Longtime User
I built a jar for the MyFirstProgram B4J demo and moved it to both the Pi3 B+ and the Pi 4. It ran correctly on the Pi 3 B+, but a little slow loading (that's maybe for another thread). And I didn't have any exit code, so I had to reboot to get out but that was expected. I then tried the Pi 4. Here are the results:

First, I checked the java installation:
pi@raspberrypi:~/Downloads $ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-post-Raspbian-5)
OpenJDK Server VM (build 11.0.3+7-post-Raspbian-5, mixed mode)

Next I checked the OpenJFX installation:
pi@raspberrypi:~ $ sudo apt-get install openjfx
Reading package lists... Done
Building dependency tree
Reading state information... Done
openjfx is already the newest version (11.0.2+1-1).
openjfx set to manually installed.
The following package was automatically installed and is no longer required:
rpi.gpio-common
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Then I tried to run the app and got:
pi@raspberrypi:~/Downloads $ java -jar MyFirstProgram.jar
Error: JavaFX runtime components are missing, and are required to run this application

I continue to be stumped.
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
That's bizarre! Why don't you try Java 8 with JavaFX overlay? It wouldn't hurt and could possibly work especially since it did work with a Pi zero!

https://chriswhocodes.com/

[optional] sudo apt update
[optional] sudo apt install raspberrypi-ui-mods
sudo unzip openjfx-8-sdk-overlay-linux-armv6hf-libbrcm-fix.zip -d /opt/jdk/jdk1.8.0_212
sudo /opt/jdk/jdk1.8.0_212/bin/java -jar YourProgram.jar


Good Luck!
 
Upvote 0

pixelpop

Active Member
Licensed User
Longtime User
Well, it was worth a try.

I did a fresh install of NOOBS.
Installed Java 8 (jdk-8u221-linux-arm32-vfp-hflt.tar.gz). Obtained from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html.
Installed JavaFX overlay (openjfx-8-sdk-overlay-linux-armv6hf-libbrcm-fix.zip).
My resulting directory structure was a little different than yours (no jdk directory):
/opt/jdk1.8.0_221 $ ls
bin include lib man release THIRDPARTYLICENSEREADME.txt
COPYRIGHT jre LICENSE README.html src.zip

Set memory split from default 64 to 128 (via raspi-config).
Reboot

Check versions:
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-post-Raspbian-5)
OpenJDK Server VM (build 11.0.3+7-post-Raspbian-5, mixed mode)

(Why does this say version 11.0.3 when I specifically downloaded Java 8 from the link above?)
openjfx is already the newest version (11.0.2+1-1).

Ran the program:
pi@raspberrypi:~/Downloads $ sudo /opt/jdk1.8.0_221/bin/java -jar MyFirstProgram.jar
* failed to add service - already in use?

This is the same error I was getting thru the B4X Bridge. This is really starting to suck!!
 
Last edited:
Upvote 0

pixelpop

Active Member
Licensed User
Longtime User
I think it's time to close this thread without a resolution. Googling JavaFX or OpenJX provides a wealth of conversations about JFX not working on the Raspberry Pi 4. I don't believe there is anything that Erel can do about this. Eventually the proper drivers/apps will come out that resolve the issue, but for now I'm going to stay on the Raspberry Pi 3 B+.
 
Upvote 0
Top