2

I am trying to call my simulation model from another java program. I followed the official instructions to have the codes like below:

package test;

public class UserMain {

public UserMain(){};

  public void start(){

    String[] args = new String[]{"D:\\user\\model\\Repast_java\\IntraCity_Simulator\\IntraCity_Simulator.rs"};

//    repast.simphony.runtime.RepastMain.main(args);
  }

  public static void main(String[] args) {

    UserMain um = new UserMain();
    um.start();
  }
}

It didn't work. I think it's due to the wrong classpath. How to configure it correctly?

Note that you need to have repast.simphony.runtime/bin and the jars in repast.simphony.runtime/lib on your classpath since the runtime needs these to start.
Jack
  • 1,339
  • 1
  • 12
  • 31
  • 2
    Can you edit your question to include the error you are getting when you try to run it? – Nick Collier Dec 03 '19 at 13:38
  • 1) I dont know how to add "repast.simphony.runtime/bin and the jars in repast.simphony.runtime/lib" on the classpath. do you mean the to add them through the configure build path of my java project? Could you provide a graphic precedures? – Jack Dec 03 '19 at 14:01
  • 2) This is what I want to do. I have a java program that need to call a python program first to do the data cleanning work. after the data cleanning, the java program will then call the repast simulation model to run the simulation, either in a single run or batch runs (need an option chooser). The output can be written to a txt file as default in batch run or a json which can be sent to other programs (mainly python). – Jack Dec 03 '19 at 14:01

1 Answers1

2

This is more of a Java or Eclipse question about how to use Java's class path. But briefly, if you are running from the command line, you can use the -cp argument to specify the classpath. A quick google should provide the details. In Eclipse, the classpath is specified in dependencies tab in the Run Configuration (Run -> Run Configurations) for your application.

Nick Collier
  • 1,786
  • 9
  • 10