Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I fix problems while running .exe file
    primarykey
    data
    text
    <p>I have a <code>ThMapInfratab1-2.exe</code>file under <code>C:\Users\Infratab Bangalore\Desktop\Rod</code> directory. I executed in command prompt in the following way.it's working fine.</p> <pre><code> C:\Users\Infratab Bangalore\Desktop\Rod&gt;ThMapInfratab1-2.exe TMapInput.txt </code></pre> <p>I want to do same procedure using <code>Java</code> technology. using <code>StackOverFlow</code> guys,I tried in 2 ways.</p> <p>Case 1:</p> <p>Using <code>getRuntime()</code>.</p> <pre><code> import java.util.*; import java.io.*; public class ExeProcess { public static void main(String args[]) throws IOException { Runtime rt = Runtime.getRuntime(); File filePath=new File("C:/Users/Infratab Bangalore/Desktop/Rod"); String[] argument1 = {"TMapInput.txt"}; Process proc = rt.exec("ThMapInfratab1-2.exe", argument1, filePath); } } </code></pre> <p>Case 2:</p> <p>Using <code>ProcessBuilder</code></p> <pre><code> import java.io.File; import java.io.IOException; public class ProcessBuilderSample { public static void main(String args[]) throws IOException { String executable = "ThMapInfratab1-2.exe"; String argument1 = "TherInput.txt"; File workingDirectory = new File("C:/Users/Infratab Bangalore/Desktop/Rod"); ProcessBuilder pb = new ProcessBuilder(executable, argument1); pb.directory(workingDirectory); pb.start(); } } </code></pre> <p>in both cases, I am getting the following error.</p> <p>Error:</p> <pre><code> Exception in thread "main" java.io.IOException: Cannot run program "ThMapInfratab1-2.exe" (in directory "C:\Users\Infratab Bangalore\Desktop\Rod"): CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at ProcessBuilderSample.main(ProcessBuilderSample.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.&lt;init&gt;(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source) ... 2 more </code></pre> <p>I did't figure out, what's the problem. can anyone suggest me.</p> <p>I am using <code>jre 7</code>.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload