1
I am running a program as follows:
Runtime.getRuntime().exec("C:\\meuprograma.exe");
In which it works normally. But I would like to package the files (the executable and a few more) within my project so that the user doesn’t have to keep manipulating the files. Moreover, the file is important only at the time of execution, so there is no need for me to create a directory to "install" the necessary files (unless this is the only solution, of course). I created a structure similar to this:
src
|__ br.foo.files
|__ br.foo.main
Assuming my class calling the executable is inside the package main
, how do I run a file within the package files
? I tried to:
Runtime.getRuntime().exec("files/meuprograma.exe");
Runtime.getRuntime().exec("./files/meuprograma.exe");
Runtime.getRuntime().exec("/files/meuprograma.exe");
In which all generated the following exception:
Exception in thread "main" java.io.Ioexception: Cannot run program "files/myprogram.exe": Createprocess error=2, System cannot find the specified file
In thesis you don’t need it. I don’t know if you have something specific from Netbeans creating a problem. What I did is essentially take the directory where the application is running. If that’s not what you want, I wouldn’t know what else to say. Tell me to remove the answer.
– Maniero
I would like to know what is the mistake here to have a -1?
– Maniero
what? No mistake, I believe.
– Renan Gomes
@rrnan actually someone went out distributing -1 in my stuff.
– Maniero