Results 1 to 4 of 4
  1. #1
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    79
    Rep Power
    0

    Default Multiple exevution of Jar file with from JAVA Code

    Hello my friend,

    I would like to ask you how can i execute the next code without errors.
    I am trying to execute a jar (myFile.jar) file multiple times with different inputs from another jar file. More simple i have game with many players and i create a Round Robin scheduling for the tournament, i need to execute all the mach's of a round together.

    When i run the next code it execute on the first game with the first players multiple times.

    Any idea ???


    Java Code:
    public class RunJARFile {
    
    //10 player
    //5 game per round
    
    public static void main(String[] args) throws IOException {
    
    
    for (int Tour = 0; Tour < 9 ; Tour++) {          
              for (int Game = 0; Game < 5; Game++) {
    
                                        player1 = Scheduling.player1Table[Tour][Game]; 
                                        player2 = Scheduling.player2Table[Tour][Game];
                                     
                                        logFile = "logfile"+Tour+"-"+Game+".log";
    
    Runtime.getRuntime().exec("cmd /c java -jar myFile.jar "+player1+" "+player2+" "+Path+" "+Pmch+" >> "+logFile+" 2>&1");
    
    }
    }
    
    }
    
    }
    Thank you in advanced

  2. #2
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Multiple exevution of Jar file with from JAVA Code

    Quote Originally Posted by ki_ha1984 View Post
    Hello my friend,

    I would like to ask you how can i execute the next code without errors.
    I am trying to execute a jar (myFile.jar) file multiple times with different inputs from another jar file. More simple i have game with many players and i create a Round Robin scheduling for the tournament, i need to execute all the mach's of a round together.

    When i run the next code it execute on the first game with the first players multiple times.

    Any idea ???


    Java Code:
    public class RunJARFile {
    
    //10 player
    //5 game per round
    
    public static void main(String[] args) throws IOException {
    
    
    for (int Tour = 0; Tour < 9 ; Tour++) {          
              for (int Game = 0; Game < 5; Game++) {
    
                                        player1 = Scheduling.player1Table[Tour][Game]; 
                                        player2 = Scheduling.player2Table[Tour][Game];
                                     
                                        logFile = "logfile"+Tour+"-"+Game+".log";
    
    Runtime.getRuntime().exec("cmd /c java -jar myFile.jar "+player1+" "+player2+" "+Path+" "+Pmch+" >> "+logFile+" 2>&1");
    
    }
    }
    
    }
    
    }
    Thank you in advanced
    From my experience, I have not been able to load a jar file directly from java, instead, you could create a batch file with those parameters and run that. It should work just fine.

  3. #3
    ki_ha1984 is offline Member
    Join Date
    Aug 2011
    Posts
    79
    Rep Power
    0

    Default Re: Multiple exevution of Jar file with from JAVA Code

    Do you have any example of batch file execution ?

  4. #4
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Multiple exevution of Jar file with from JAVA Code

    Quote Originally Posted by ki_ha1984 View Post
    Do you have any example of batch file execution ?
    Java Code:
    java -jar /path/to/jar.jar %param#1 %param#2 %param#3
    And so on.

    Just because the code is in a 'Java Code' tag, it is not java. Just saying that before gimbal or jim gets on me.

Similar Threads

  1. Replies: 5
    Last Post: 07-09-2013, 04:06 PM
  2. Replies: 2
    Last Post: 03-12-2013, 11:17 AM
  3. Replies: 5
    Last Post: 03-26-2012, 08:11 PM
  4. Replies: 5
    Last Post: 07-17-2011, 01:50 AM
  5. multiple java files with single connection code
    By hitesh in forum Advanced Java
    Replies: 7
    Last Post: 11-23-2010, 09:18 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
  •