B4J Tutorial [ABMaterial] How to run it on a Raspberry Pi

How to run ABMaterials on a Raspberry Pi

Using:
B4J v7.51
OpenJDK11
Raspberry Pi 3 and Asus Tinkerboard
DietPi image 6.25.3
Chrome, Firefox and Edge
The project 'Demo' from ABMaterial4.30.zip

1.
Copy the Demo folder from the zip-file to your B4J projects folder.
To develop a good habbit,
Goto Objects/www and delete css, font and js folders.
Replace with the newest css, font and js folders from the zip-file.
Compile Demo.b4j in debug to create copymewithjar.needs
Compile Demo.b4j in Release
2.
Download a DietPi image from dietpi.com
Follow Getting started at dietpi.com/phpbb/viewtopic.php?f=8&t=9#p9
Download Putty, a SSH client, from www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Use Putty to connect to your Pi.
Login as root, pw dietpi.
At first boot you will be guided through different settings:
Change global password.
Change users passwords.
Disable seriel TTY.
In DietPi-Software, change SSH Server from Dropbear to OpenSSH
3.
After the Reboot, Login as root, Install Java with these commands:
wget https://github.com/bell-sw/Liberica...4/bellsoft-jdk11.0.4-linux-arm32-vfp-hflt.deb
sudo apt-get install ./bellsoft-jdk11.0.4-linux-arm32-vfp-hflt.deb
java -version
, test that java is installed.
4.
Download WinSCP, a SecureCoPy client, from https://winscp.net/download/WinSCP-5.15.3-Setup.exe
Start WinSCP
You can delete /root/bellsoft-jdk.......... file
In left side, navigate to \Demo\Objects folder
In right side, navigate to /usr folder
Right click and create demo folder and go to demo folder
I left side, select all files from Objects folder and press Upload
In right side, go back to the root folder
Right click and select New-File, name it demo.sh, inset these 2 lines:
cd /usr/demo
nohup java -jar Demo.jar > nohup.out

Remeber that demo.jar and Demo.jar are two different files :)
5.
Start Putty
Login as root
Start the ABM Demo, bash demo.sh
Start a browser and goto http://your-Pi-IP:51042/demo
6.
Last task is to make the server run at boot and with no user logged in.
Start Putty and start dietpi-config
Go to AutoStart Options, select 14:Custom
This creates this script
/var/lib/dietpi/dietpi-autostart/custom.sh
Start WinSCP
In right side, navigate to /var/lib/dietpi/dietpi-autostart folder
Right click custom.sh and select Edit
Add this line at the bottom: bash /root/demo.sh
Thats it.


Useful commands:

Monitor the logs with:
tail -f /usr/demo/nohup.out

Find the process number:
ps -ef | grep java

Kill the server:
kill <process number>

Find a file:
cd /
find . -name <name of file or directory> -print | more

Update everything.
apt-get update

Delete unused packages:
apt autoremove
 

Cableguy

Expert
Licensed User
Longtime User
You should mention which Raspberry pi board your tutorial is targeting as there seems to be some differences between the pi3 and pi4...
Or at least, mention "Tested with pi X board"
 
Top