kensvebary
kensvebary

Reputation: 513

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!

Upvotes: 0

Views: 787

Answers (1)

jaguar.huang
jaguar.huang

Reputation: 26

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 ");

Upvotes: 1

Related Questions