如何使用Wscript Exec运行Java文件 [英] How to use Wscript Exec to run a Java file

查看:177
本文介绍了如何使用Wscript Exec运行Java文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为Wscript:String值的描述,指示用于运行脚本的命令行:命令行的显示应与在命令提示符下键入时的显示完全一样.

As the description of Wscript:String value indicating the command line used to run the script: The command line should appear exactly as it would if you typed it at the command prompt.

我可以使用命令"java test http://www.bbc.co.uk/news/world-us-canada-12116778"运行我的Java文件 但是当我在下面编写JavaScript时,它不起作用.有人可以告诉我为什么吗? 谢谢或者可以告诉我打开html文件时还有其他方法可以调用Java文件吗?

I can run my java file using the command "java test http://www.bbc.co.uk/news/world-us-canada-12116778" but it is not working when I wrote the JavaScript below. Can someone can tell me why? Thank you or can tell me there is some other method to call my Java file when I open a html file?

<script type="text/javascript">
funciton {}
var WshShell = new ActiveXObject("WScript.Shell");
var oExec= WshShell.Exec(""java test http://www.bbc.co.uk/news/world-us-canada-12116778"");
while (oExec.Status == 0)
{
     WScript.Sleep(100);
}
</script>

推荐答案

看看WSHSell对象的

Take a look at the WSHSell object's run method. The following code works for me:

var shell = new ActiveXObject("WScript.Shell");
shell.run("cmd /c java -jar MyApplication.jar");
// should work without JARs as well, take care for the working path

run方法可以选择等待Java程序返回.

The run method has an option to wait for the java program to return.

希望这会有所帮助.

这篇关于如何使用Wscript Exec运行Java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆