如何从 Java 执行外部程序?

发布于 2024-08-04 20:23:24 字数 624 浏览 4 评论 0原文

可能重复:


我想从 Java 执行 Perl 程序。

获取带有参数的文件名并执行程序,Perl 程序输出结果文件。

所以这是JAVA的程序方面

  1. 我指定一个参数并执行Perl程序
  2. Perl程序读取我吐出的文件

2)检查文件的存在并且似乎能够做到这一点,但是1)可能? ActivePerl 随当前机器一起安装。我在 Eclipse 上开发 Java。

Possible duplicates:


I want to execute a program of Perl from Java.

I take a file name with an argument and carry out a program, and the program of Perl outputs a result file.

So it is the program side of the JAVA

  1. I appoint an argument and carry out Perl program
  2. Perl program reads the file which I spitted out

2) checks the existence of the file and seems to be able to do it, but will 1) be possible? ActivePerl is installed with the present machine. I develop Java on Eclipse.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝梦月影 2024-08-11 20:23:24

使用:

String command = "ls";    
Runtime.getRuntime().exec(command);

参考:执行命令

仅供参考:该链接包含以下示例带参数的命令,也带空格。

Use:

String command = "ls";    
Runtime.getRuntime().exec(command);

Reference:Executing a Command

FYI: The link contains examples of commands with arguments, and with spaces too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文