I tried the following code:

   import java.io.*;

   public class runabl {
       public static void main( String[] args )
    {
       try{
        Runtime rt = Runtime.getRuntime();

        Process prcs = rt.exec( "a.out" );
        System.out.println("Inside try");
        System.out.println(prcs);
           }
       catch( Exception e ) {
         System.out.println("Catch something");
         System.out.println(e);
       }
     }
   }

However, the output is :

   Inside try
   java.lang.UNIXProcess@156d6e

instead of the result from typing "a.out" directly.



On May 12,  7:08pm, Bill Wandrack wrote:
> Subject: Re: How to make a system call in Java
> You can make system calls with java by using Process.
>
>
> String command = "mkdir new_dir";
> Process createNewDir = Runtime.getRuntime().exec(command);
>
>
>
> Yuet Sim Lee wrote:
>
> > I am writing a Java code which has to
> > call another C-program.  I knew that
> > C has a system call, exec or system.
> >
> > Are there any similar system call in Java?
> >
> > ----------------------------------------------------------------------
> > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > with a subject of "unsubscribe". Trouble? Contact
[EMAIL PROTECTED]
>
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact
[EMAIL PROTECTED]
>
>-- End of excerpt from Bill Wandrack



----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to