I am trying to interact with a simple .exe I created from some Python code. I have tested the .exe through Windows cmd and it works just fine. When I try to send the same input to the .exe through my java program to produce the graphs I need, OutputStream just writes “error” to the console. I have tried sending a string and an integer through OutputStream but the same results are obtained no matter what. I have already interacted with X-Foil.exe, a console application use to produce airfoil data files, with great success through this same java app. As I have to preform curve fitting to the data, I used Python with the matplotlib plugin then used py2exe to create the .exe. I am trying to create a web application with the end goal of designing an aircraft wing, hence the use of java. Here is the method being use which I am having the problem with:
public void PyGrapher(String NACA_4d) {
try {
ProcessBuilder builder = new ProcessBuilder("PyAirfoilGraphing\\dist\\GraphPolars.exe");
builder.redirectErrorStream(true);
Process pr = builder.start();
OutputStream out = pr.getOutputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
double CL_alpha;
out.write((NACA_4d + "\n").getBytes());
System.out.println(in.readLine());
System.out.println(in.readLine());
System.out.println(in.readLine());
System.out.println(in.readLine());
//CL_alpha = Double.parseDouble(in.readLine());
pr.waitFor();
pr.destroy();
out.close();
in.close();
} catch (IOException | InterruptedException ex) {
}
}
Here is what I have read in from the console:
Input NACA 4-digit code: error
Traceback (most recent call last):
File "GraphPolars.py", line 16, in <module>
IOError: [Errno 2] No such file or directory: '..\\..\\AirfoilPolars\\NACA_0024.dat'
I am stumped, and have been for quite some time. There is not a problem with the python file, and it runs fine by itself in the current directory. Can anyone help, please?
-Nick K
Could it be something with relative paths? Python default path may not be picking up the local directory/file.
Did you try passing it the full windows path, ‘C:\Foo\bar\AirFoil\… ‘ with properly escaped ‘\’ characters?