我有一份Java、Ada、C和Python编写的二进制文件列表,我想执行它们。 我该怎么做? 这些语言是否有与JVM相关的绑定库?
如果您只想执行现有的应用程序,可以使用java.io.runtime
命名空间中的exec
方法。
Runtime rt = Runtime.getRuntime();
Process ps = rt.exec("path to my executable.exe");
// run the Unix "ps -ef" command
// using the Runtime exec method:
Process p = Runtime.getRuntime().exec("ps -ef");
您几乎可以在其中放置任何命令,但我遇到的唯一问题是要注意系统环境变量,例如您正在运行JVM的PATH。
如果您想与二进制API交互,请使用以下方法: