I know it has been asked before, but none of those answers seem to work for me. I am trying to get a .exe file running in a java program. The following code (that I plucked from Internet) works; Notepad starts.
import java.io.IOException;
public class start {
public static void main(String args[])
{
try {
Process p = Runtime.getRuntime().exec(new String[] {"C:\\Windows\\System32\\notepad.exe"});
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
But when I change the folder to the one that contains my own .exe file, it doesn't do anything. It doesn't even give an error. It just starts and terminates. If I double-click the file in the folder itself, it just opens and runs, so the file itself works.
So, just to be clear, I changed Process p
to
Process p = Runtime.getRuntime().exec(new String[] {"C:\\Users\\Sharonneke\\Documents\\IntraFace-v1.2\\x64\\Release\\IntraFaceTracker.exe"});
Why won't this work and how do I fix it?
Update:
So I don't have to use the new String []
but that doesn't solve the problem. Also, using the ProcessBuilder (like kage0x3b said in the answer section) gives the error: "The constructor ProcessBuilder(String) is undefined"
while it apparently should work like that :(