Reputation: 11
So im trying to make an auto typer right now all i want the program to do is open Google Chrome. Im on a mac so its not a .exe file. The name of the file is (Google Chrome.app) The space in the name confuses me. Heres my code
package com.mycompany.autotyper;
import java.awt.AWTException;
import java.awt.Robot;
import java.io.IOException;
public class AutoTyper {
public static void main(String[] args) throws AWTException, IOException {
String str = "Hello World!";
Robot rb = new Robot();
Runtime rt = Runtime.getRuntime();
rt.exec("Google Chrome.app");
}
}
Upvotes: 1
Views: 505
Reputation: 4604
For me it worked:
Runtime rt = Runtime.getRuntime();
rt.exec("open -a /Applications/Google\\ Chrome.app");
My Google Chrome.app is currently present in /Applications folder.
Use \\
for reading space of file name.
Upvotes: 1