I am having a problem launching textedit from a Java application. It was working a week ago on a fresh iMac, but since then I have installed CS2, the Macromedia Studio MX suite, and some other programs and now the textedit program does not start from my Java app. This is the code that I am using in my application to launch textedit:
I've also tried it this way:
I've printed the command to execute out on the console and it appeared like this:
But it doesn't open textedit. The funny thing is, if I copy and paste that open command into the Terminal, it will open the file in TextEdit. Why won't it work in my Java app anymore, but still work through the terminal? I don't get any errors in the console, it just doesn't open TextEdit anymore. Is there a setting somewhere that might have been changed that let me start TextEdit from a Java app. I checked and TextEdit is still my default program for opening text files, which I guess makes since why it works from the Terminal, but I don't get why it doesn't start TextEdit from my Java app.
I'm using Java 1.5.0_07. Thanks for your help
Code:
String command = "open -e \""+filename.getAbsolutePath()+"\"";
Runtime rt = Runtime.getRuntime();
rt.exec(command);
I've also tried it this way:
Code:
String command = "open -e \""+filename.getAbsolutePath()+"\"";
Process child = Runtime.getRuntime ().exec (command);
I've printed the command to execute out on the console and it appeared like this:
Code:
open -ef "\Users\user\Desktop\filename.txt"
I'm using Java 1.5.0_07. Thanks for your help