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 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。