简体   繁体   中英

How do I set a .java program in startup in a Raspberry PI?

I've tried searching for other answers on the web, but I haven't found a working solution yet. I have a .java application (developed with NetBeans 8.2) and I want to set it to start when my PI boots up.

Starting a java program and executing a command on startup are two different concerns, but you can write a script that executes your java program and tell Linux to load it on startup.


CD to the PI folder.

cd ~

Create a script that runs your java program:

sudo nano runjava
java <your program and arguments>

Save and exit: Ctrl + X , Y , Enter

Now open up .bashrc to configure the startup:

sudo nano .bashrc

And add this to the bottom of the file.

./runjava

Save and exit: Ctrl + X , Y , Enter

This would run the program every time you log in.

PS : You might need to provide +x permission on the script ( chmod ).

Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM