This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Run a ProC or C file from Java

 
Atanu Das
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am able to run a notepad.exe from java code by

<blockquote>code:
<pre name="code" class="core">import java.io.*;
import java.util.*;

class runProc
{

public runProc()
{
try {
String[] cmd = {"notepad.exe"}; // C://TCC//ADG.EXE substitute notapad with this.
Process p=Runtime.getRuntime().exec(cmd); //tell the path.
p.waitFor();
System.out.println("i am in try block");
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{

runProc runP = new runProc();
}
}
</pre>
</blockquote>
this code. but, if I want to run a C exe file or a pro C file from Java , then How to do that??
Please reply
[ July 16, 2008: Message edited by: Atanu Das ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

What differentiates an executable written in C from any other executable like notepad.exe? Or, to put it another way, what exactly happens when try it?

Make sure you handle the input/output/error streams as this article explains.
 
Atanu Das
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
You can run my code to see the problem. It is giving some error (16bit MSDOS error) as:

C:\WINDOWS\SYSTEM32\NTVDM.EXE
ERRORR WHILE SETTING UP ENVIRONMENT FOR THE APPLICATION.


PLEASE HELP AS EARLY AS POSSIBLE.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!