B4J Tutorial Companion thread to B4J Training Video 5 - Bridge Scripts

As promised in this the B4J Training Video about the Bridge, I am attaching the scripts for running the Bridge from Mac or Raspberry Pi (Linux):

Mac:
1) Create a file called bridge.sh
2) Insert the following code into the script and then set it to run via Terminal
B4X:
cd /
cd ~/Documents/development/b4j
java -jar b4j-bridge.jar
3) Simply double-click the script BEFORE you bring up your virtual Windows environment and note the IP

Raspberry Pi (Linux):
1) Create a file called bridge.sh
2) Insert the following code into the script and then set it to run via LX Terminal
B4X:
#/bin/bash
cd ..
cd /home/pi/Downloads
sudo java -jar b4j-bridge.jar
3) Double-click the script and then 'Execute in Terminal'.
4) Note the IP to compare to the B4J IDE connection

A couple of quick notes which may alleviate some potential frustration:
* If you want to run a UI app on the Raspberry Pi, you should have JDK 8u6 (NO HIGHER supports JavaFX) AND the RPi needs to be connected to a "hard" display, NOT VNC.
* When compiling a web server app, you have to manually copy the WWW folder to the target machine because the static files are within the folder.

Please, let me know if anything isn't clear o_O ....
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
To share in addition for (extensive) developments on the RPi, I am using a Bash script which is executed at boot and starts the B4J-Bridge. The output is directed to a log file. When B4J is started, press F2 and the connection is made. Make the life of a (hobby) developer (bit) more easier.

Bash Script b4jbridge.sh
B4X:
#/bin/bash
sudo /usr/bin/java -jar /home/pi/b4j/b4j-bridge.jar > /home/pi/scripts/b4jbridge.log &
Ensure to make the script executable: $sudo chmod 755 /home/pi/scripts/b4jbridge.sh.
Do not forget the & sign in the script.

Crontab Entry
B4X:
@reboot sudo /home/pi/scripts/b4jbridge.sh
Added via crontab -e

Logfile showing B4J connections
B4X:
B4J-Bridge v1.00
Waiting for connections (port=6790)...
My IP address is: 192.168.0.39
Connected!
Error: (SocketException) java.net.SocketException: Connection reset
Waiting for connections (port=6790)...
My IP address is: 192.168.0.8
Connected!
Error: (SocketException) java.net.SocketException: Connection reset
Waiting for connections (port=6790)...
My IP address is: 192.168.0.8
Connected!
Error: (SocketException) java.net.SocketException: Connection reset
Waiting for connections (port=6790)...
My IP address is: 192.168.0.8
Connected!
Starting program
ProcessCompleted
Starting program

Thanks Mark for the tutorials. Well Done.
 

Mark Turney

Active Member
Licensed User
Longtime User
Thank you too Rob ... I have learned a lot from your threads and excellent website!
 
Top