I have deployed my Rest API on Tomcat 7.
It is deployed at following path :
/var/lib/tomcat7/webapps/myproject
And I have a Jar file which is kept at this location :
/home/user/executor/datacollector.jar
I am getting problem while running this jar from my application. It is not running when called using this code.
My code for running it is :
ProcessBuilder pb = new ProcessBuilder("java", "-jar", "/home/user/executor/datacollector.jar");
Process p = pb.start();
ResultStream resultStream = new ResultStream(p.getInputStream());
Thread thread = new Thread(resultStream , "resultStream");
thread.start();
public class ResultStream implements Runnable {
private static Logger logger = Logger.getLogger("ResultStream");
private BufferedReader reader;
public ResultStream(InputStream is) {
this.reader = new BufferedReader(new InputStreamReader(is));
}
public void run() {
try {
String line = reader.readLine();
logger.info("line - "+line);
while (line != null) {
logger.info(line);
line = reader.readLine();
}
reader.close();
} catch (IOException e) {
logger.error("IOException in executing jar",e);
// e.printStackTrace();
}
catch (Exception e) {
logger.error("Error in executing jar",e);
// e.printStackTrace();
}
}
}
Is there anything wrong in path, because It is outside webapps folder of Tomcat.
Please point out my mistake.