简体   繁体   中英

Starting a Java program on startup (Automatically - Raspberry Pi)?

I try to start my Java program (Class file) on Startup (Raspberry Pi). For that, i used .bash_profile to start xinit with the startx command. In .bash_profile now the command line looks like this:

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor

This command starts xinit, but I also need to start my own Java program after xinit has started. For Example: Just need to put somewhere the command java classname so it can execute my class file automatically (But i dont know where).

Java Program actually needs to execute chromium-browser (It works if i type java classname manually):

ProcessBuilder pb = new ProcessBuilder("bash", "-c", "DISPLAY=:0 chromium-browser --disable-infobars --kiosk http://www.google.com"); Process processX = pb.start(); // Start the process. processX.waitFor(); // Wait for the process to finish.

Have you try adding exec java path-to-your-java-file in your .xinitrc? that will usually just execute the program after startx I think.

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