I'm trying to help out a friend who is trying to run a Python script from Java. Right now, here's my code:
Java:
public class test {
public static void main(String[] args) {
System.out.println("Hello world!");
try {
Runtime.getRuntime().exec("cmd /c start C:/Users/User/Documents/python/runFile.bat");
} catch (IOException e) {
e.printStackTrace();
}
}
}
Batch:
@echo off
python test.py
pause
Python:
print("Hello")
input()
If I run the batch file, it prints Hello like it should. But when you run the Java file, it brings up this command prompt error:
"'python' is not recognized as an internal or external command, operable program or batch file."
It seems like this error comes up when you need to edit the PATH variable in Windows, but that's set up already. And like I said, this is only a problem when it runs from Java.