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

pixelpop

Active Member
Licensed 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.
 

Cableguy

Expert
Licensed User
What type of app (UI/NON UI), if UI, are you aware of the limitations due to the lack of jfx support in official java?

I don't use the Bridge, I copy the app to the SD and run it from the command line...
 

pixelpop

Active Member
Licensed User
MyFirstProgram is the starter code that Erel provides as part of the B4J installation. Attached is its UI.

The UI issue was resolved starting with Java 8. I am on Java 11 and it does support UI.

https://www.b4x.com/android/forum/threads/raspberry-pi-with-java-11.99606/#content

I think my issue may lie in the lack of JFX in my installation. I'm hoping the Erel can shed some light on if this is the case and if so, what version to get and perhaps where to get it.

Edit: I believe I found the JFX download. Just need to know which one to get (and where to deploy it, Windows or Raspberry Pi).

https://gluonhq.com/products/javafx/
 

Attachments

Last edited:

pixelpop

Active Member
Licensed User
Erel,

Unless the JFX libraries were part of the 11.0.1 release (your reference above) and were not part of 11.0.4 (my reference in the initial comment), then I don't think that is the issue. I also just checked and there have been several releases since your tutorial (11.0.4, 12.0.2, and 8u222). Are you saying that the 11.0.1 release should be used? I may just start over and try 11.0.1, but you need to make it explicit because most users will try to use the latest release.
 

pixelpop

Active Member
Licensed User
OK, I will just start from scratch and try 11.0.1. Just FYI -- the number of files in 11.0.1 is 176 and the number of files in 11.0.4 is 155. So something changed between the two releases.
 

pixelpop

Active Member
Licensed User
Maybe I am misunderstanding your tutorial. I am fairly software literate but new to the RPi. So forgive me if I ask some questions that others might view as really basic.

In the tutorial, the first step is:

Running UI apps on Raspberry Pi with Java 11 is relatively simple.

1. Download Liberica JDK: https://www.bell-sw.com/java-for-raspberry-pi-11-preview.html
Download the lite version: https://github.com/bell-sw/Liberica...ft-jdk11.0.1-linux-arm32-vfp-hflt-lite.tar.gz


Which of these two downloads is the one to use? The first link directs the user to version 11.0.4, which I think we already determined was wrong. The second link downloads the correct version (or the tested version upon which this tutorial is based). I skipped the first download and just did the second one.

2. Copy it to the RPi and unpack it:
tar -xvf bellsoft-jdk11-linux-arm32-vfp-hflt-lite.tar

Does it matter where it is copied to on the RPi (because wherever it is copied to is where it be located when it's unpacked)? I put it in my Downloads folder, so it unpacked to Downloads/jdk-11.0.1/. Is this the proper location for it?

3. Download the latest version of b4j-bridge (1.41+).
wget www.b4x.com/b4j/files/b4j-bridge.jar

No problem with this step. This also went into my Downloads directory.

4. Run b4j-bridge:
sudo jdk-11/bin/java -jar b4j-bridge.jar

No problem here except that the path names may be different depending on where Java and B4J-Bridge were unpacked.

Maybe I am viewing this with a Windows bias where installed app and driver locations of the files matter. Even when I side-load an app on Android I don't concern myself with the "where is" and directory structures of the installation. Maybe the RPi does not have a registry and everything just runs from wherever it is.

Any enlightenment would be greatly appreciated.
 

pixelpop

Active Member
Licensed User
As a follow-up, the 11.0.1 version does load the JavaFX modules. I then connected the Bridge, compiled and ran "MyFirstProgram." The errors generated are shown in the attached pic.

The Bridge load and connection looks like this on the RPi:

pi@raspberrypi:~/Downloads $ sudo jdk-11.0.1/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: javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.web
Connected!
Starting program
ProcessCompleted


Any ideas?
 

Attachments

pixelpop

Active Member
Licensed User
I forgot that I had copied "OpenJDK 11 + OpenJFX 11" to c:\java as suggested that as part of your tutorial. But I just unzipped and copied the contents. Does it need to be "installed"? It currently is not listed in Windows "Uninstall a program" list.

In the c:\java directory I have C:\java\javafx\bin and C:\java\javafx\javafx-jmods. Does the The javafx.swing error (first error in error list) correspond to the javafx.swing.jmod file found in the C:\java\javafx\javafx-jmods directory?

PS - I found this in the B4J Q&A:

Q: What are the requirements for UI apps developed with B4J?
A: Java 8u40+ is required. B4J UI apps will run on Windows, Mac and Linux computers.

Since MyFirstProgram is a UI app, should this be installed in addition to OpenJDK 11 + OpenJFX 11? 8U221 is the currently available version.
 
Last edited:

Erel

Administrator
Staff member
Licensed User

pixelpop

Active Member
Licensed User
Well, I'm stumped then. When I compile and run MyFirstProgram on my PC (as a standalone without a Bridge connection), it runs without errors. And when I start the Bridge on the Pi it seems to start OK:

pi@raspberrypi:~ $ cd Downloads
pi@raspberrypi:~/Downloads $ sudo jdk-11.0.1/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: javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.web


But when I connect to the Pi via Bridge and compile, I get all those errors in post #9.

PS - I ran a version check and go this:

pi@raspberrypi:~ $ 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)
pi@raspberrypi:~ $


I don't even know where 11.0.3 came from. How do I uninstall it and try to install 11.0.1 again?

PPS - I got rid of 11.0.3 using sudo apt-get remove openjdk*. The java -version command now returns Java not installed. I then unpacked 11.0.1 again, but still get the same compile errors.
 
Last edited:

pixelpop

Active Member
Licensed User
Well, I am out of options. I have reinstalled the bare-bones Raspbian Buster with desktop(https://www.raspberrypi.org/downloads/raspbian/) to make sure no Java was included (I believe it is in NOOBS). I have followed every step of installing Java 11.0.1 and B4J Bridge using the source links provided in Erel's tutorial. Everything seems to track exactly to the tutorial until I try to run MyFirstProgram. Then I get the errors shown in msg #9 above and the app does not appear on the Raspberry Pi desktop. It runs without any errors and displays the app on Windows 10 when the bridge is not connected.

The last thing I will try is to repeat this procedure on a Raspberry Pi 3 B+ instead of the Raspberry Pi 4. If it works I'll report back here; if it doesn't I'm going to have abandon this very promising development environment. I had high hopes based on my previous experience with B4A, but maybe it's just not meant to be. :(
 

pixelpop

Active Member
Licensed User
OK, I have had success on the Raspberry Pi 3 B+. I still get the same warnings, but now the debugger connects and the app is displayed full screen on the Pi.

WARNING: Unknown module: javafx.swing specified to --add-opens
WARNING: Unknown module: javafx.swing specified to --add-opens
WARNING: Unknown module: javafx.swing specified to --add-opens
WARNING: package com.sun.glass.ui.win not in javafx.graphics
WARNING: package com.sun.prism.d3d not in javafx.graphics
WARNING: Unknown module: javafx.swt specified to --add-opens
WARNING: Unknown module: javafx.swing specified to --add-opens
Waiting for debugger to connect...
Program started.


The only thing I did differently on the Raspberry Pi 3 B+ was start Bridge without FTP and allocate more memory to the GPU (64K as installed; I upped it to 256K). I will keep working with the Raspberry Pi 3 B+ until I get it solid and then I'll go back to the Raspberry Pi 4. I think the GPU memory may have been the issue. Still curious about all those warnings, though. ;)
 

pixelpop

Active Member
Licensed User
Using the same configuration but upping the GPU memory to 512K, I still can't get MyFirstProgram to display. Aside for those warnings, the only message is:

Dispman: Cannot open display
* failed to add service - already in use?

Maybe the Raspberry Pi 4 has a architecture change that B4J needs to account for. I'm disappointed I can't develop on the Raspberry Pi 4, but I'll move back to the Raspberry Pi 3 B+ and develop on there. Hope that a fix for the Raspberry Pi 4 will be forthcoming.

Thanks, Erel! I really do appreciate everything you do for the B4X community.
 
Top