I am trying to figure out how to reference a python file so that I can execute it within a Java GUI Jar. It needs to be a portable solution, so using absolute paths will not work for me. I have listed my project structure below, and have included the code for how I am trying to execute the python script..I have read things about using resources, but I have been unable to implement this successfully. I appreciate any help you can provide!
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("python /scripts/script.py");
BufferedReader bfr = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
while((line = bfr.readLine()) != null)
System.out.println(line);
}
catch(Exception e) {
System.out.println(e.toString());
}
}
--OneStopShop (Project)
--Source Packages
--images
--onestopshop
--Home.java
--scripts
--script.py
can't open file: '/scripts/script.py': No such file or directory)