Results 1 to 3 of 3

Thread: Implement dos command in java

  1. #1
    Harvey Lavan is offline Member
    Join Date
    Sep 2009
    Posts
    57
    Rep Power
    3

    Default Implement dos command in java

    I am working on live project where I use JAVA programming language. I want to implement DOS command in JAVA.. Still now I have done this, but not quite what I am expecting.
    Code:
    try {
                Runtime.getRuntime().exec("shutdown-a");
               }catch(Exception e){
                System.out.System.out.println("error");
            }
    If you are having any suggestions then reply me. It can helpful to me.

  2. #2
    Join Date
    Sep 2009
    Posts
    53
    Rep Power
    3

    Default

    This is because "dir" sends a response to the output stream. And when you make a Runtime. exec must use the flow and when the command has a number of arguments (‘shutdown’ and '-a') should be run through a table. I think this should be pretty easy for you because java provides a good number of api's for the same. Hope you will do the needful.

  3. #3
    Join Date
    Sep 2009
    Posts
    68
    Rep Power
    3

    Default

    What is the system running this command?
    Linux DIR no
    Code:
    [ex @ usr ~] DIR $
    -bash: DIR: command not found
    Is this what you are trying to do in your code, then you must understood that both the OS are different and if depends on which OS you are on. If you are on Linux like OS then this will not work.

Similar Threads

  1. What are Command-Line Arguments in Java?
    By MorganCooper in forum Programming
    Replies: 2
    Last Post: 02-22-2010, 03:44 PM
  2. knowledge of programming Implement
    By FosterWood in forum Programming
    Replies: 1
    Last Post: 02-09-2010, 06:26 PM
  3. Ls command for MAC OS X
    By LewisClark in forum Operating System
    Replies: 2
    Last Post: 02-09-2010, 02:17 PM
  4. Implement a Software Firewall on a Linux
    By SmithJohnson in forum Networking Jargons
    Replies: 0
    Last Post: 12-29-2009, 04:44 PM
  5. How to Implement Encryption & Security in Information Systems
    By ScottWright in forum Networking Jargons
    Replies: 0
    Last Post: 12-23-2009, 06:15 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48