My code:
ProcessBuilder builder = new ProcessBuilder();
builder.command("n");
File file = new File("..");
builder.directory( file );
try {
Process p = builder.start();
} catch (Exception e) {
System.out.println(e);
}
Eclipse says:
java.io.IOException
Cannot run program "n" (in directory ".."): CreateProcess error=2, The system cannot find the file specified
But the file n.txt is there, if I say:
for(String fileNames : file.list()) System.out.println(fileNames);
It's listed: n.txt.
Same problem if I substitute "n.txt
" with "n
" in the sourcecode or try to call a .exe
;
System.out.println(file.getCanonicalPath());
Creates
F:\Programme\eclipse\workspaces\test
This:
System.out.println(builder.directory().getAbsolutePath());
Creates
F:\Programme\eclipse\workspaces\SimulatorAddOn\SimulatorAddOn\..
And substituting
ProcessBuilder builder = new ProcessBuilder();
builder.command("n");
with
ProcessBuilder builder = new ProcessBuilder("n");
Doesn't change anything either.
I need your help guys. Thanks in advance