...

View Full Version : run C exe from JAVA



DasAtanu
07-01-2008, 11:56 AM
I am unable to run a C exe from java.It is possible to run a notepad.exe from java but, when I am trying to run a C exe, it is giving an environment 16 bit MS DOS error.

the code:

try{
Runtime rt = Runtime.getRuntime();
String[]callAndArgs= {"notepad.exe"}; // {C:\\TCC\\ADG.EXE} for C exe
rt.exec(callAndArgs);


System.out.println("I am in try block");
}
catch(Exception e)

or


try {
String[] cmd = {"C:\\TCC\\ADG.EXE"};
Process p=Runtime.getRuntime().exec(cmd); //tell the path.
p.waitFor();
System.out.println("i am in try block");
}
catch(Exception e)
{
e.printStackTrace();
}
the error:
C:\windows\system32\ntvdm.exe
Error while setting up environment for the application.

Please reply asap.

shyam
07-01-2008, 06:46 PM
there is another overloaded exec method in the Runtime class where you can set up the environment variables for a particular executable

DasAtanu
07-16-2008, 09:20 AM
Hi Shyam,
Can you please help me with the code..?It will be very much helpful to me.

Zed
03-29-2009, 12:58 PM
There is an easy sol. to ur prblem I had the same a few days ago... ur code can run a 32 bit exe but not a 16 bit exe but u must hv compiled ur C code using a TC compiler that produses a 16 bit exe rather try some 32 bit compiler like DJGPP to make an exe of ur C code and then use the same code u posted above it'll work fine...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum