### Autostart

Example of automating the B4J-Bridge by 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.
Install B4J-Bridge
in folder /home/pi/b4j.
mkdir /home/pi/b4j
wget http://www.b4x.com/b4j/files/b4j-bridge.jar
Check if the B4J-Bridge is located in /home/pi/b4j:
ls /home/pi/b4j
Autostart Option - Crontab calls Jar
Edit crontab:
sudo crontab -e
To make the changes, select an editor > nano is easiest to use (Option 2)
Add to crontab the line:
@reboot sudo java -jar /home/pi/b4j/b4j-bridge.jar &
Save
Autostart Option - Crontab calls Bash Script
Create Bash Script b4jbridge.sh
cd /home/pi/scripts
sudo nano b4jbridge.sh
with content:
#!/bin/bash
sudo /usr/bin/java -jar /home/pi/b4j/b4j-bridge.jar > /home/pi/scripts/b4jbridge.log &
Do not forget the & sign in the script!
Make Script executable
sudo chmod 755 /home/pi/scripts/b4jbridge.sh
Add Script to Crontab
crontab -e
To make the changes, select an editor > nano is easiest to use (Option 2)
Add to crontab the line:
@reboot sudo /home/pi/scripts/b4jbridge.sh
Logfile Example showing B4J connections
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

Changed: 2017-12-06 14:05, Category: B4J-Bridge, File: T6C164M1210.htm, ID: 1210