- 论坛徽章:
- 0
|
简化后大概如下:
甲类:
if(e.getSource() == startJB) // start the service of this server. there is no real function now;
{
/*
try{
et = new ExamThread();
}catch(Exception eee){
nullError("测试系统启动失败!","系统");
}
*/
try { // try to start the service of exam online
setLog("启动在线测试服务器...");
Runtime testR = Runtime.getRuntime();
testR.exec("java ExamServer start");
nullError("已启动在线测试服务器!","系统");
startJB.setEnabled(false);
stopJB.setEnabled(true);
setLog("启动在线测试服务器成功!");
}catch(Exception exxx){
System.err.println("Runtime %Wrong:"+exxx.toString());
}
//this.chatStart();
}
if(e.getSource() == stopJB) // stop the service of this server. there is no real function now;
{
try { // try to start the service of exam online
setLog("关闭在线测试服务器...");
Runtime testR = Runtime.getRuntime();
testR.exec("java ExamServer stop");
nullError("已关闭在线测试服务器!","系统");
startJB.setEnabled(false);
stopJB.setEnabled(true);
setLog("关闭在线测试服务器成功!");
startJB.setEnabled(true);
stopJB.setEnabled(false);
}catch(Exception exxx){
System.err.println("Runtime %Wrong:"+exxx.toString());
}
乙类:
public static void main (String args[])
{
if(args[0].toString().equals("start"))
{
...运行的主程序
System.out.println("starting ...*"+args[0]);
}
else if(args[0].toString().equals("stop"))
{
...要求关闭主程序
System.out.println("stoped!*"+args[0]);
}else
{
System.out.println("请使用java ExamServer start|stop!");
}
}
ps:现在主要是再次调用java ExamServer stop 时不能关闭之前运行的ExamServer |
|