View Full Version : run C exe from JAVA

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:

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

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


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

Please reply asap.

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

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

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