aspose file tools*
The moose likes Java in General and the fly likes Run a ProC or C file from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Run a ProC or C file from Java" Watch "Run a ProC or C file from Java" New topic
Author

Run a ProC or C file from Java

Atanu Das
Greenhorn

Joined: Jun 30, 2008
Posts: 4
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 ]

Atanu Das<br />India
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42273
    
  64
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.


Ping & DNS - my free Android networking tools app
Atanu Das
Greenhorn

Joined: Jun 30, 2008
Posts: 4
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Run a ProC or C file from Java