CreateProcess error=2, The system cannot find the file specified
winrar.exe is in the
Runtime.exec is capable of finding it, if it is not, you will need to supply the fully qualified path to it, for example, assuming
winrar.exe is installed in
C:/Program Files/WinRAR you would need to use something like...
p=r.exec("C:/Program Files/WinRAR/winrar x h:\\myjar.jar *.* h:\\new");
Personally, I would recommend that you use
ProcessBuilder as it has some additional configuration abilities amongst other things. Where possible, you should also separate your command and parameters into separate
String elements, it deals with things like spaces much better then a single
String variable, for example...
ProcessBuilder pb = new ProcessBuilder(
Process p = pb.start();
Don't forget to read the contents of the
InputStream from the process, as failing to do so may stall the process
How to fix "CreateProcess error=2, The system cannot find the file specified" even if the Path variable is specified (crossplatform)
The reason you are getting that error on Windows is because you are not giving it the full name, including the extension. You don't have to give it the full path as long as the containing directory is in the
You can type
mvn in the Windows command interpreter (cmd.exe), and it will work because is somewhat clever about extensions. But Groovy and Java doesn't go through that.
.execute() method delegates to Java's
ProcessBuilder, which on Windows calls a native function called
CreateProcess in the win32 API. In this function, if you do not specify an extension, it will assume it is a
.exe file. This is why the
where command work (which is actually
git (which is actually
git.exe) but not other executable types like
.cmd, such as
To fix it in a way that is compatible with multiple platforms, the best option I see is to check which platform is used and alter the command accordingly. Something along these lines:
def mvnFileName = System.properties['os.name'].toLowerCase().contains('windows') ? 'mvn.cmd' : 'mvn'
def mvnbuild = "$mvnFileName package".execute() // ...
Error:java: Cannot run program CreateProcess error=2, The system cannot find the file specified
IDEA doesn't necessary use
JAVA_HOME variable. The project SDK (JDK in your case) is setup in the project settings: File -> Project Structure, Project SDK and set up the proper path there.
CreateProcess error=2, The system cannot find the file specified [Android studio]
Since android studio is still referring to jdk1.7.0_40 change its path
Goto Files->Other Settings->Default Project Structure.
Under Platform Settings Select Android sdk...under JDK location change C:\Program Files (x86)\Java\jdk1.7.0_40 to C:\Program Files\Java\jdk1.7.0_45
That should do the trick :)
Error message: createProcess error=2, The system cannot find the file specified
I just fixed this by setting sdk and ndk in local.properties
For me it was adding those lines at the end of the file :
sdk.dir=C:\Users\luou\AppData\Local\Android\Sdk (It was already there)
Maven - exec-maven-plugin - CreateProcess error=2, The system cannot find the file specified
...as documented (& shown) instead.