I'm trying to run a python script whenever a button on my gui (swing) is pressed. However, the script never runs and I'm not sure how to fix this. I know the script works fine independently, it should be py not python because windows, and my file system ntfs.
So far I've been trying to use code that can be summarized as below:
myBtn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
          Process p = Runtime.getRuntime().exec("py myScript.py");
        } catch (IOException ioe) {
          ioe.printStackTrace();
        }
      }
});
I don't think I can chmod ntfs stuff but I tried setting permissions via right clicking the python file and trying to mess with the security settings. Full control for the script to users does nothing.
The python script has the following permissions, my guess is my code isn't working because it does not have execute permissions.
-rw-r--r--

Runtime.execand would instead useProcessBuilder, it's more configurable. You should also make sure you're consuming the output and error streams, for example. You might also find this example helpfulmyScript.pyis relative. Maybe call anotherexecvariant to give it the working directory as parameter.ProcessBuilderto the rescue. You might also find this other example helpfulpyitself is being called (with a very simple script, e.g. writing actual time to a file) ((it normally is not a good idea to do long time processing on the EDT))