Results 1 to 11 of 11
  1. #1
    pradeesh is offline Member
    Join Date
    Dec 2008
    Posts
    4
    Rep Power
    0

    Question Running batch files in java

    Hi,

    How can i run two batch files in a specified interval(Eg. 1 hour) using java.

    Thanks

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Runtime.exec and java.util.Timer

  3. #3
    pradeesh is offline Member
    Join Date
    Dec 2008
    Posts
    4
    Rep Power
    0

    Default

    Can u please explain?

    import java.io.*;
    class RunBat{
    public static void main(String arg[]){
    try{
    String command = "cmd /C start C:/google.bat ";
    Runtime rt = Runtime.getRuntime();
    rt.exec(command);
    }catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

    I have code for running only one batch file, but i need to run two batch files in an interval of one hour.

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Read the API docs for java.util.Timer. If you see a Class name that you don't recognise, that should be the first thing you do.

  5. #5
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Links...

  6. Java API link:
  7. Java Platform SE 6
  • Specific Timer API link:
  • Timer (Java Platform SE 6)


  • Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
    Reply With Quote Reply With Quote

  • #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Someone at the Sun Forums has already given him some code.

  • #7
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Dang...

    Cross poster...
    New To Java - Running batch files using java
    That really angers me ... too bad

    Thank masijade for letting me know about the cross post.

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  • #8
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, to tell you the truth, I don't really see anything wrong with posting on multiple sites (but I do for posting in multiple forums on the same site), as long as the OP keeps all threads "up-to-date". Which this one, did not.

  • #9
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default hhhmmm...

    Not so sure I agree...
    • If everything & everybody were perfect/responsible, yeah I would probably agree, but....
    • Since history has taught that we are just beings (notice the missing "human" part), and are VERY imperfect, I don't agree, therefore...
    • My vision would be to stick to one forum until a solution is obtained. If a satisfactory answer/solution is not obtained, then go to another forum.


    Thanks anyway...
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  • #10
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by CJSLMAN View Post
    • If everything & everybody were perfect/responsible, yeah I would probably agree, but....
    Which, of course, is why I said as long as they keep all others "up-to-date" (which many, many, many people won't).

    Now, for something simple, like this, I wouldn't do it either. But for something much more complicated, it makes sense, as, although many users are members of many forums, each forum will have a few good posters that are not members of other forum, and on something complicated I would want the widest possible audience (of course, that would mean I start on Sun's forums and stay there alone, for a while, and then, if I am not satisfied post on multiple other platforms, but with all info gleaned to that point and periodic updates on all of them).

    P.S. Members, don't get me wrong, I am not saying this forum is not good, but I would trust the vendors own forum site for a product to have more knowledgeable members than most others. No insult intended. ;-)

    Edit: And hopefully none taken. ;-)

  • #11
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Interesting...

    ... and yes I guess that I would go first to Sun's forum (it does has more traffic), but the issue is the cross posting. Posters probably don't realize the effects of cross posting... they're only thinking about their java problem.
    On a positive side, the volunteer responses here on the Java forums is much nicer than the Sun forums (they tend to be more demanding and less forgiving).
    I suggested to the mods a sticky post with recommendations about the forum use and among those recommendations was to avoid cross posting. For some reason, which I never understood, the suggestion didn't stick (the admins didn't like it... go figure).

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  • Similar Threads

    1. Batch Files in java
      By coco in forum New To Java
      Replies: 3
      Last Post: 12-05-2008, 02:30 PM
    2. Batch file to Run Java application
      By nitishlnt in forum Eclipse
      Replies: 1
      Last Post: 10-24-2008, 08:46 PM
    3. running java
      By Winarto in forum New To Java
      Replies: 1
      Last Post: 08-22-2008, 07:40 AM
    4. running .class files on a website
      By jklsemicolon in forum Networking
      Replies: 10
      Last Post: 08-08-2008, 07:21 AM
    5. conversion of java .class files to .java files
      By kotturupraveen in forum New To Java
      Replies: 2
      Last Post: 06-09-2008, 01:58 PM

    Posting Permissions

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