I'm trying run a Python file with argument in Java code. When I run the file in Mac Os terminal, it works perfectly, but when I tried in Java code, it doesn't work.
In terminal I type this:
python import.py 10477 > out.txt
That command generates a out.txt correctly, but it doesn't work in my Java code. I tried with this:
String path = "/Users/Atlas/Desktop/Job/Python";
String textValue = textFixVersion.getText(); # Get value from a TextBox
if(releaseRadio.isSelected()) { # Radio Button
String terminal = "python import.py " + textValue + " > out.txt";
try {
Process process = Runtime.getRuntime().exec(terminal,null,new File(path));
}
catch (IOException ex) {
Logger.getLogger(Atlass.class.getName()).log(Level.SEVERE, null, ex);
}
}
This code is the same when I execute Jar files within my Java code and it working perfectly. I'm working with Python 3.9.10.