I have a web application script written in Python that I store in my resources folder. I can access the file without a problem, but I am having trouble executing the script after deploying my Java application. To launch the script I have:
File f = new File(this.getClass.getClassLoader.getResource("/InterWebApp.py").getFile());
Process process = Runtime.getRuntime().exec("python " + f.getPath());
process.waitFor();
This does not launch the script, or if it does the process is dying immediately. When a monitoring class looks at process
every 120 seconds, the process is not alive. I am deploying my application on a company platform and simpler processes like gedit newFile
do work and launch the window, but I cannot get my Python script to launch, which I am assuming is because when the process is launching it might not have direct access to the resource files. Any ideas?
EDIT: I have also tried:
String scriptFilePath = System.getProperty("user.dir") + "/src/main/java/com/pkg/resources/InterWebApp.py";
Process process = Runtime.getRuntime.exec("python " + scriptFilePath);
I've tried an absolute path before, but the issue I have is the working directory when I deploy my application contains a JAR containing the resources and not the directory structure specified in the absolute path.