I'm trying to execute a Java program from within a Python program.
import subprocess
subprocess.run("ls") # ok
subprocess.run("whoami") # ok
subprocess.run("java --version") # not ok
I can run standard shell commands but not the Java executable. Why is that?
Traceback (most recent call last):
File "syscall.py", line 4, in <module>
subprocess.run("java --version") # not ok
File "/usr/lib/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'java --version': 'java --version'