B4J Question Run program at startup

ThRuST

Well-Known Member
Licensed User
Longtime User
EDIT:

How to make a B4J application autostart on Windows, Macintosh, Linux, Solaris, Ubuntu, Qubes, and any other O/S that can run Java Virtual Machine.
Every relevant solution is welcomed. Thanks
 
Last edited:

ThRuST

Well-Known Member
Licensed User
Longtime User
Raspberry Pi Autostart B4J Application

On a Raspberry Pi there are various ways to setup Autostart of a Jar file.

One way is by editing (using the nano editor), as User root, the file /etc/rc.local and add, before exit 0,
following code for the application rpiconsole.jar:
$cd /etc
$nano rc.local

B4J Server Application weathercubeone
cd /home/pi/b4j/webapps/weathercubeone
/usr/bin/java -jar weathercubeone.jar &

Or

B4J Non-UI Application TFWeatherToDomoticz
cd /home/pi/domoticz/scripts
/usr/bin/java -jar tfweathertodomoticz.jar &

Checks after Reboot
Login as Pi

To list all processes:
$ps -ef

To dedicated check for process weathercubeone
$ ps -ef | grep weathercubeone
Output Example:
root 2138 1 1 20:12 ? 00:00:07 /usr/bin/java -jar weathercubeone.jar

Kill Process
Select the PID and invoke using above PID
$kill 2138
Note:
If permission error, set root priviledge:
$sudo -i

 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Autostart on Windows
Put a shortcut in the Startup folder.
C:\Users\<your username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

The problem is just, how to find the username for the local computer? And how does this work on Mac etc?

This might work. Not tested yet
Dim name As String = GetEnvironmentVariable("COMPUTERNAME", "")
Or perhaps
Dim name As String = GetEnvironmentVariable("USERNAME", "")
Then write to the Windows registry by using jSLPreferences Library available Here
Also jShell Library might be a better alternative.

Your comments and posts are welcomed. Thanks
 
Last edited:
Upvote 0
Top