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";
}
but somehow, although, this function is being executed, it stops in like 10-20 seconds.But if I run the jar file from the command prompt – it works just fine
I ended up with the solution above.