B4J Question Run B4J App at Startup on Pi


Active Member
Licensed User
Longtime User
I'm really struggling to get my B4J app to run at startup on Raspberry Pi. It runs perfectly when I start it using b4j-bridge from my laptop. The app is non-UI.

I know how to put a command line in rc.local on the Pi but can't work out what file to put there?

I have found ASyncInput2.zip in the tempjars folder (with Erel's help) and this contains my .class files (including main.class) but (i) no sign of a .jar file and (ii) it is a .zip file anyway so I doubt I can reference the files within it at startup.

It's not just from startup, I can't work out any way to start the program on the Pi without using b4j-bridge connected from my laptop.

Am I missing something here? Does B4J even create a .jar file for my application on the Pi?


Well-Known Member
Licensed User
Longtime User
This might help = Sharing how I install apps on the RPi. Note that there are many other ways as well.
Lets assume the non-ui app is called myapp.

  • The myapp.jar file is created on the development device in folder Objects of the B4J Project.
  • Logon the Raspberry Pi as User Pi.
  • Create a folder /home/pi/myapp.
  • Copy myapp.jar (and any additional files required) from the development device Objects folder to the Raspberry Pi folder /home/pi/myapp.
    Note: One way is by using WinSCP. Ensure all files are copied to the RPi.
  • Goto folder /home/pi/myapp (cd /home/pi/myapp).
  • Create a file myapp.sh with content below (sudo nano myapp.sh):
    cd /home/pi/myapp
    sudo java -jar myapp.jar&
  • Save the file - Note: do not forget the ampersand & to start myapp.jar
  • Make the file executable: sudo chmod 755 myapp.sh
  • Add myapp.sh to crontab: sudo crontab -e
  • Add the line to crontab: @reboot sudo /home/pi/myapp/myapp.sh
  • Save
  • Reboot the Pi
  • Check if the process myapp.jar is running (ps -ef | grep myapp)
Upvote 0