Results 1 to 4 of 4

Thread: Restart main

  1. #1
    Syahrul is offline Member
    Join Date
    Nov 2009
    Posts
    12
    Rep Power
    0

    Default Restart main

    How do i restart main class?

    I've created irc socket bot and want to restart the program after closing the stream and socket.

    Thank you

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Syahrul View Post
    How do i restart main class?

    I've created irc socket bot and want to restart the program after closing the stream and socket.

    Thank you
    If you main( ... ) method looks like this now:

    Java Code:
    public static void main(String[] args) {
    
       // a whole lot of code here that doesn't belong here to start with
    }
    ... change it to this:

    Java Code:
    public static void main(String[] args) {
       while(true)
          doWork(args);
    }
    private static void doWork(String[] args) {
    
       // the entire bunch of code here ...
    }
    kind regards,

    Jos

  3. #3
    Syahrul is offline Member
    Join Date
    Nov 2009
    Posts
    12
    Rep Power
    0

    Default

    What command should i put to restart it? :confused:
    Thank you

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Syahrul View Post
    What command should i put to restart it? :confused:
    Thank you
    You did read my reply didn't you? The version I suggested executes the code that was originally in your main( ... ) method over and over again; just as you wanted. No special 'commands' or whatever; Java is not Basic.

    kind regards,

    Jos

Similar Threads

  1. Replies: 6
    Last Post: 11-04-2009, 09:41 PM
  2. how to include restart merkers in a JPEG file
    By ananta_javaforums001 in forum Networking
    Replies: 0
    Last Post: 04-09-2009, 03:29 PM
  3. Make application restart itself
    By Singing Boyo in forum New To Java
    Replies: 1
    Last Post: 03-22-2009, 02:49 AM
  4. Application restart in tomcat.....
    By jithan in forum New To Java
    Replies: 1
    Last Post: 09-10-2008, 03:31 PM
  5. Restart a For loop and increment an Int value
    By dcnorman07 in forum New To Java
    Replies: 1
    Last Post: 07-12-2008, 12:24 AM

Posting Permissions

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