Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    run C exe from JAVA

    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:
    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

    Code:
    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.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    there is another overloaded exec method in the Runtime class where you can set up the environment variables for a particular executable
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Shyam,
    Can you please help me with the code..?It will be very much helpful to me.

  • #4
    Zed
    Zed is offline
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    the error is basically because yuor code can run a 32 bit...

    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...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •