webservice运行Netlogo程序有问题,求帮忙
我把我写的代码先打上来,看有没有人可以帮忙下.急需!先谢谢了
如果单独在机器上是可以直接运行Netlogo的软件的,但用webservice的时候出错
package Model;
import java.awt.EventQueue;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import javax.jws.WebMethod;
import javax.jws.WebService;
import org.nlogo.api.CompilerException;
import org.nlogo.app.App;
/**
*
* @author Andy2u
*/
@WebService
public class Artefactweb {
protected void createSimulatorInstance() {
// create a new netlogo instance
String[] arg = new String[0];
App.main(arg);
// open the model file
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
try {
App.app
.open("Flocking.nlogo");
} catch (IOException ex) {
ex.printStackTrace();
}
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
@WebMethod
public void init() {
// create a simulator instance
createSimulatorInstance();
try {
// set up the model
// the case of the RandomWalk model, create the agents with an
// initial position (0,0)
App.app.command("setup");
} catch (CompilerException e) {
e.printStackTrace();
}
}
@WebMethod
public void run() {
try {
// run the go procedure (here our policy is to run only one-by-one
App.app.command("go");
} catch (CompilerException e) {
e.printStackTrace();
}
}
public static void main (String[] args){
Artefact a = new Artefact();
a.init();
}
}