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

Discussion in 'B4J Questions' started by pixelpop, Aug 6, 2019.

  1. pixelpop

    pixelpop Active Member Licensed 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: Aug 9, 2019
  2. pixelpop

    pixelpop Active Member Licensed 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.
     
  3. Amin Ismail

    Amin Ismail Member Licensed 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.....
     
    Erel and inakigarm like this.
  4. pixelpop

    pixelpop Active Member Licensed 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.
     
  5. Amin Ismail

    Amin Ismail Member Licensed 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
     
  6. pixelpop

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

    Amin Ismail Member Licensed 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!
     
  8. pixelpop

    pixelpop Active Member Licensed 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: Aug 13, 2019 at 7:23 PM
  9. pixelpop

    pixelpop Active Member Licensed 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+.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice