dqteh7347 2012-03-11 18:58 采纳率: 100%
浏览 94
已采纳

试图在Java中复制PHP exec()函数

I'm trying to replicate PHP's exec function in a Java application. Here's the PHP code:

exec('C:/executer.au3');

And here is the Java code:

Runtime.getRuntime().exec("C:/executer.au3");

When I run that I am getting an IOException saying:

Exception in thread "main" java.io.IOException: Cannot run program "C:/executer.au3": CreateProcess error=193, %1 is not a valid Win32 application
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    at java.lang.Runtime.exec(Runtime.java:615)
    at java.lang.Runtime.exec(Runtime.java:448)
    at java.lang.Runtime.exec(Runtime.java:345)
    at Executer.execute_captcha_check(Executer.java:248)
    at _ProjectAmsterdam.main(_ProjectAmsterdam.java:36)
Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32 application
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:189)
    at java.lang.ProcessImpl.start(ProcessImpl.java:133)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
    ... 5 more

I'm a bit out of my element, how can I get this au3 file to open in Java?

  • 写回答

2条回答 默认 最新

  • drqefnd544707688 2012-03-11 19:04
    关注

    The file you mention is an autoscript file that does not do anything by itself. Like a text file.

    You probably need to supply the program that will run the file - the Autoit.exe program for example.

    Runtime.getRuntime().exec("/Path/To/Autoit.exe C:/executer.au3");
    

    Along those lines - I cannot test at the moment.

    The PHP exec version may somehow trigger the default program for .au3 files. That's just a guess.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改