简体   繁体   中英

How to run chromium-browser from Java App (on RaspberryPi)?

as the title suggests, I have a problem running chromium-browser from my Java App that is running on RaspberryPi (not sure last part is relevant). I need my App to open the browser in kiosk mode and then close it after a specified amount of time. But so far I wasn't able to start the browser.

Earlier I successfully started OMX Player from my App, so I used the same approach here :

try {
ProcessBuilder pb = new ProcessBuilder("bash", "-c", "chromium-browser http://www.google.com ");
Process process = pb.start(); // Start the process.
process.waitFor(); // Wait for the process to finish.
} catch (Exception e) { ...}

But no luck. I also tried using Runtime, but again no luck :

try {
Process p = Runtime.getRuntime().exec("chromium-browser http://www.google.com");
p.waitFor();
} catch (Exception e) { ... } 

Can you guys help me out please? I'm getting kind of desperate here.

Thanks!

If you are running your Java App as Root, try this out. It works for me:

ProcessBuilder pb = new ProcessBuilder("bash", "-c", "sudo -u pi chromium-browser http://www.google.com ");

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