Java Runtime Exec Ioexception Error=2
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Createprocess Error=2 Android Studio
this site About Us Learn more about Stack Overflow the company Business Learn createprocess error=2 svn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question createprocess error=2 intellij x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up
Processbuilder Createprocess Error=2, The System Cannot Find The File Specified
CreateProcess error=2, The system cannot find the file specified up vote 7 down vote favorite 2 I am writing a program in java which would execute winrar and unzip a jar file for me placed in h:\myjar.jar into the folder h:\new. My java code goes something like this import java.io.File; import java.io.IOException; public class MainClass { public static void main(String[] args) { Runtime r=Runtime.getRuntime();
Cannot Run Program ""c:/program":createprocess Error=2, The System Cannot Find The File Specified
Process p=null; try { File dir=new File("C:/Program Files/WinRAR"); p=r.exec("winrar x h:\\myjar.jar *.* h:\\new",null,dir); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } When i execute this, i am getting this error java.io.IOException: Cannot run program "winrar" (in directory "C:\Program Files\WinRAR"): CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at MainClass.main(MainClass.java:16) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.
Certification Databases Caching Books Engineering Languages Frameworks Products This Site http://stackoverflow.com/questions/19621838/createprocess-error-2-the-system-cannot-find-the-file-specified Careers Other all forums Forum: Beginning Java java.io.IOException: Cannot run program ""C:/Documents": CreateProcess error=2,cannot find file Shantanu Nandan Greenhorn Posts: 1 posted https://coderanch.com/t/634480/java/java-io-IOException-run-program 2 years ago import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxProfile; public class download { public static void main(String[] args)throws Exception{ FirefoxProfile profile=new FirefoxProfile(); profile.setPreference("browser.download.folderList",1); profile.setPreference("browser.helperApps.neverAsk.SaveToDisk", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); profile.setPreference("browser.download.dir", "C:\\Documents and Settings\\OMEGA\\Desktop\\Selenium Download"); WebDriver window=new FirefoxDriver(profile); WebElement wb; try{ window.get("http://www.shine.com/myshine/login/"); window.manage().window().maximize(); window.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); wb=window.findElement(By.id("id_email")); wb.sendKeys("sweta.xxx@gmail.com"); window.findElement(By.id("id_password")).sendKeys("123456"); window.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); window.findElement(By.id("btn_login")).click(); wb=window.findElement(By.xpath("//a[@style='float:left']")); String href=wb.getAttribute("href"); window.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); String command="\"C:/Documents and Settings/OMEGA/Desktop/Selenium Download.exe\""+ " "+href; Runtime.getRuntime().exec(command); window.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); System.out.println("Done")
Certification Databases Caching Books Engineering Languages Frameworks Products https://coderanch.com/t/438445/java/java/java-io-IOException-CreateProcess-error This Site Careers Other all forums Forum: Java in General java.io.IOException: CreateProcess: error=2 Dilanka Muthukumarana Greenhorn Posts: 11 posted 7 years ago hey all.. I tried to run java code to access shut.bat file to shutdown remote computer.so I use batch commands.but result createprocess error is the following exception.. "java.io.IOException: CreateProcess: shut.bat 127.0.0.1 Dilanka keepintouch error=2" in this file username is dilanka and password is keepintouch.. this is ma code sample: I have already included "shut.bat" , psshutdown.exe and shut.class files in the suitable folder.. please help me to createprocess error=2, the run this program. shut.bat file psshutdown.exe -k -u %2 -p %3 -t 5 \\%1 shut.java public synchronized void run(){ boolean temp=false; System.out.println("shut run " +"shut.bat "+this.IPaddr+" "+this.User+" "+this.Passwd); try{ p = Runtime.getRuntime().exec("shut.bat "+this.IPaddr+" "+this.User+" "+this.Passwd); // newly added##### //String cmd = "shut.bat"+this.IPaddr+" "+this.User+" "+this.Passwd; //p = Runtime.getRuntime().exec(cmd); // ########### System.out.println(p); System.out.println("Shutdown is in progress "); in = new BufferedReader(new InputStreamReader(p.getErrorStream())); line=null; while ((line = in.readLine()) != null){ //System.out.println(this.IPaddr+line); if(!temp) //mw.updateMsg(this.IPaddr+" --- > "+"Connecting ....."); System.out.println(this.IPaddr+" --- > "+"Connecting ....."); if(line.equals("Sysinternals - www.sysinternals.com")) temp=true; if((temp==true) && (!line.equals("")) && !line.equals("Sysinternals - www.sysinternals.com")) //mw.updateMsg(this.IPaddr+" --- > "+line); System.out.println(this.IPaddr+" --- > "+line); } }catch(IOException io){ System.out.println(io); } } Steve Luke Bartender Posts: 4181 22 I like... posted 7 years ago The rest of the error message for that "error=2" error is "No such fi