[英]How to execute a .class file(java) from .py script?
I was doing a project on my RaspberyPi, when I stumbled onto this problem: I need a python script to run a java file, but can't find a way to do that.当我偶然发现这个问题时,我正在我的 RaspberyPi 上做一个项目:我需要一个 python 脚本来运行 java 文件,但找不到这样做的方法。 The files are start.py and main.class and are in the same folder.
这些文件是 start.py 和 main.class 并且位于同一文件夹中。
What you want to do is use python to execute a bash command (assuming you're on linux), you'd use the same command to run a java file which is java main
where main
is main.class
What you want to do is use python to execute a bash command (assuming you're on linux), you'd use the same command to run a java file which is
java main
where main
is main.class
here's a simple script that uses subprocess
to run the command这是一个使用
subprocess
运行命令的简单脚本
import subprocess
cmd = 'java main'.split(' ')
subprocess.run(cmd)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.