CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 1999
    Posts
    9

    Java command line



    Hi,

    does Anyone know how to execute a command line command from within java code?

    I am using windows N.T. and i would like to execute a command from a Java program.


    Thanks.


    charbel.

  2. #2
    Join Date
    May 1999
    Posts
    93

    Re: Java command line



    See the docs for the class Runtime. The exec() method is probably what you

    are looking for

  3. #3
    Join Date
    Feb 1999
    Posts
    9

    Re: Java command line



    Hi,

    Thanks for replaying to my message i have used the following :



    String classPath = "d:\\javastar\\javastar.zip;f:\\bkw1\\lib\\rescue.zip;c:

    \jdk1.1.6\\lib\\classes.zip;F:\\bkw1\\source\\classes;d:

    \\jdk\\lib;d:\swingall\\swingall.jar ";

    Runtime comp = Runtime.getRuntime();

    comp.exec("javac -classpath "+classPath+" "+filename);



    but it seems that nothing happens when i run the program!!!!!!!.



    what i want is to have:

    javac -classpath d:\\javastar\\javastar.zip;f:\\bkw1\\lib\\rescue.zip;c:

    \\jdk1.1.6\\lib\\classes.zip;F:\\bkw1\\source\\classes;d:

    \\jdk\\lib;d:\\swingall\\swingall.jar filename

    executed at the command prompt.



    thanks.





    charbel



  4. #4
    Join Date
    Feb 2001
    Location
    india
    Posts
    2

    Re: Java command line

    plese get the args values into the variables in your programe and display it back if more than one args loop it


    vinay kumar s.v

  5. #5
    Join Date
    Jan 2000
    Location
    CA, USA
    Posts
    305

    Re: Java command line

    Try the foll. if you are working in windows os.

    comp.exec("cmd /c javac -classpath "+classPath+" "+filename");


  6. #6
    Join Date
    Feb 2001
    Location
    India
    Posts
    2

    Re: Java command line

    but how to give the input from one process to another process started by a java program.
    sanjubose


  7. #7
    Join Date
    Dec 2000
    Location
    Belgium
    Posts
    264

    Re: Java command line

    Hi,

    Recently, I posted this:
    http://codeguru.earthweb.com/bbs/wt/...a&Number=15098

    You can easily couple an output stream of one process to an output stream of another process using the information in this post.

    Regards,
    Geert Arys

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured