B4J Tutorial Remote debugging with B4J-Bridge

B4J v1.80 adds support for remote debugging using B4J-Bridge, a tool similar to the beloved B4A-Bridge.

The purpose of B4J-Bridge is to allow you to connect the IDE to a remote machine such as a Mac computer or a Raspberry Pi board and to easily debug your app on the remote machine. The connection is done over the network (usually the local network).

Instructions
  • Download b4j_bridge.jar to the remote machine: www.b4x.com/b4j/files/b4j-bridge.jar
    Note that you can download it with this command:
    B4X:
    wget www.b4x.com/b4j/files/b4j-bridge.jar
    Tip: delete the previous version before download: rm b4j-bridge.jar
  • Make sure that Java 8+ is installed on the remote machine.
  • Open a terminal and run java -jar b4j-bridge.jar:

    SS-2014-03-13_13.13.11.png


    If you are running it on a raspberry pi together with the jPi4J library then you need to run it with:
    B4X:
    sudo java -jar b4j-bridge.jar
  • Choose Tools -> B4J-Bridge -> Connect and enter the remote machine IP address:

    SS-2014-03-13_13.14.43.png

  • The status icon should change to:

    SS-2014-03-13_13.15.43.png

  • Now you can run your app in Release or Debug mode and debug it directly on the target machine:

    SS-2014-03-13_13.17.27.png
You can disconnect with Shift + F2 and later reconnect with F2.
Note that the jar is copied to the target machine and deployed under a folder named tempjars.

If the debugger fails to connect to the remote machine then you should open the following ports for incoming connections:
59812, 8937 and 8938

Updates

v1.50 - Adds support for signed Mac Java 14. See the Java section here: https://www.b4x.com/android/forum/threads/building-notarized-mac-packages.130890
v1.44 - Adds support for Java versions above Java 11.
 
Last edited:

jcohedman

Member
Licensed User
Longtime User
Hi, it works!
but... in "Debug" mode don't, "Error: JavaFX runtime components are missing, and are required to run this application"
and in Release mode, if I write in the rpi: sudo /home/pi/jdk8/bin/ java -jar "my_app".jar, it is working.
What can be wrong?
thanks in advance.
 

MbedAndroid

Well-Known Member
Licensed User
Longtime User
there is no way to debug on distance? even when i set the portforward?
I tried to insert a external Ip adress but that isnt accepted
 

MbedAndroid

Well-Known Member
Licensed User
Longtime User
ok, i see
if i start to enter a new Ip, you will get "invalid adress" until i entered all the numbers.

thought it was already rejected on the the first group of the ip number

sorry
 

Starchild

Active Member
Licensed User
Longtime User
Great addition.

I successfully tried using FTP FileZilla to access my remote Linux development box (ubuntu) using the FTP server of b4j-bridge v2.20.

Works great, but it is limited by the available root on the Linux box being the TempJars folder.

It would be useful to be able to move higher up the directory tree so the b4j-bridge FTP server could be used to access other directories/files. Maybe another command line switch.

Anyway, it's a very simple and useful addition for quickly moving application support files onto the Linux box.

Thanks.
 

ajk

Active Member
Licensed User
Longtime User
OMG super tool. My mac is lucky. Erel you are great !

Added _2020_06_01_
Chapeau bas Erel ! My VPS server remote debugging works !
 
Last edited:
Top