i got two questions.
Where is the directory the Method Runtime.getRuntime().exec()
gets its resources from?
if i am calling Runtime.getRuntime().exec("notepad.exe")
, why does it start the windows editor? Where does java gets the .exe source from?
based on this question, i have to let the user choose, if he wants to open a file in an editor, which editors he prefers, and wants to use. He only writes in something like notepad.exe
or ultraedit.exe
and the choosen file will be opened in the editor written down here. At the moment, i am opening a file with this Method
public void open(String path) {
try {
if(new File(path).exists())
Runtime.getRuntime().exec("notepad.exe " + path);
} catch (IOException e) {
e.printStackTrace();
}
}
So as you can see every file will be opened within the notepad. But i need to have something like this :
public void open(String program, String path) {
try {
if(new File(path).exists())
Runtime.getRuntime().exec(program + " " + path);
} catch (IOException e) {
e.printStackTrace();
}
}
So is there any possibility to open txt files in different editors, by just calling their .exe file?