I have a jar file that is required to be run on the jsp page. jar file is designed to be executed in the command line. This is my code:
public static String scheduleCourses() throws IOException {
String execute = "java -jar execute.jar "jdbc:mysql://localhost:3306/db" root "" file.txt";
Process process = Runtime.getRuntime().exec(execute);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
try {
process.waitFor();
} catch (InterruptedException ex) {
Logger.getLogger(widgets.class.getName()).log(Level.SEVERE, null, ex);
return "Error with import<br>" +ex;
}
return "All done";
}
但是,虽然这个函数正在被执行, 它在10 -20秒内停止。 但是如果我从命令中运行罐子文件, 就会很快, 它的工作效果很好。