My question is how can i can exit chrome using java please answer with a imports and package im a beginner :)
i tried: but i know that exec(String command) gets a a specified system command so its wrong there is another way ?
package com.tutorialspoint; public class ProcessDemo { public static void main(String[] args) { String url = "https://www.youtube.com/watch?v=Ei3Vymb_lFM&list=PLqKCUR6vbEfxGeSCePPlk7hH-mpIdqlpg&index=1"; try { // create a new process System.out.println("Creating Process..."); Process p = Runtime.getRuntime().exec(url); // wait 10 seconds System.out.println("Waiting..."); Thread.sleep(10000); // kill the process p.destroy(); System.out.println("Process destroyed."); } catch (Exception ex) { ex.printStackTrace(); } } } the massage i got is Creating Process... java.io.IOException: Cannot run program "https://www.youtube.com/watch?v=Ei3Vymb_lFM&list=PLqKCUR6vbEfxGeSCePPlk7hH-mpIdqlpg&index=1": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at java.lang.Runtime.exec(Runtime.java:620) at java.lang.Runtime.exec(Runtime.java:450) at java.lang.Runtime.exec(Runtime.java:347) at com.tutorialspoint.ProcessDemo.main(ProcessDemo.java:14) at Browser.main(Browser.java:39) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.(ProcessImpl.java:386) at java.lang.ProcessImpl.start(ProcessImpl.java:137) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 5 more
destroy()(edit the question, don't add a comment).