Results 1 to 8 of 8
  1. #1
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default Java that runs like a .bat?

    Ok so I was trying to accomplish opening 4 .exe's with delays inbetween each opening. Why do I need this? Because these .exe's must be fully loaded before the next one opens or it won't load properly. One establishes a MYSQL virtual server, one loads the databases from the MYSQL VS, the next opens the tables and the other loads the game server. Now if they don't open in this exact order, or they load before the previous program completes loading it will error out and terminate.

    Now I was scouring the internet for how to do this in a bat file but to no avail. Everything required the other window to close, or user input. I'm trying to make it completely automated. I have no problem hard coding the timer into the program because it always takes the same amount of time to load.

    Is there a way to make a Java program load an exe, not inside itself but like the start notepad.exe command in a batch file would? I'm not asking for a handout here, but any pointers in the right direction of discovery would help me alot. I haven't found anything that makes sense on google. Then again over 75% of the pages on google are blocked on my connection...
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default

    Are you looking for Runtime.getRuntime().exec()?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    I'm not sure, I'm going to look at that now to see if that's what I'm trying to do.

    Just curious, but did what I wrote make any sense? I'm low on sleep and I'm on energy drink #5... But I'm trying to setup this morale network right now and it has to be done ASAP. So I'm trying to make a program that I can make run on startup that will host these games. The startup part is easy, I thought batch was the way to go but I can't figure out how to do it and I know a lot more java than I know windows commands so I am trying to find out how to solve my problem.

    The idea of having it fully automated is so that any one can restart the computer and all the game servers will start back up upon restart. That way no one has to be shown how to run everything.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default

    I don't know if there's a sure-fire way to guarantee a Java program runs at startup (you could add it to the startup folder or use a .bat (I think) that runs at startup to launch a Jar), but I don't think those are portable solutions.

    What you said makes sense, and it sounds like you're looking for exec(). Or you might want to look at ProcessBuilder: ProcessBuilder (Java Platform SE 6)

    To be honest, I'm not extremely familiar with this stuff (as you can probably tell), but it sounds like this is what you're looking for.

    PS- I love your signature.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    I don't need it to be portable, so I'm just placing a .bat in the startup that starts my program. Real easy because it will only be placed on one computer.

    I'll take a look into those two, thanks a lot. Hopefully I'll be able to figure it out.

    P.S. Thanks, I got tired of posting it in every thread that had code outside of the tags.
    Last edited by Dark; 04-15-2011 at 07:42 PM.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  6. #6
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    I looked into exec, and I wrote a quick program that opened a file, now I just have to make it loop and have a timer. A little more work, but I'll figure it out.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default

    Quote Originally Posted by Dark View Post
    I looked into exec, and I wrote a quick program that opened a file, now I just have to make it loop and have a timer. A little more work, but I'll figure it out.
    Very cool. What else do you need to do with the loop and timer? From your original description, it seems like Thread.sleep() might be enough for your purposes. But I might be missing something.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    It is indeed, I was working on it for hours after starting this thread and I got it working except for one portion. If you would like to offer your two cents the new thread containing the problem I have with my code now is here.

    New Thread: exec problem, compiles but no output?
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

Similar Threads

  1. Replies: 8
    Last Post: 03-10-2011, 08:00 PM
  2. Best XML parser that runs on J2SE
    By noonproxy in forum XML
    Replies: 2
    Last Post: 03-07-2011, 10:04 AM
  3. App runs on one system but not the other?
    By PMurph in forum New To Java
    Replies: 7
    Last Post: 11-15-2010, 04:53 AM
  4. java.util.Scanner runs in Vista but not in Linux
    By pellebye in forum New To Java
    Replies: 6
    Last Post: 08-24-2009, 04:50 AM
  5. [SOLVED] App runs only in IDE
    By hannehomuth in forum Advanced Java
    Replies: 4
    Last Post: 07-15-2009, 07:41 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
  •