从html< script> -node运行Java代码 [英] Running Java code from html <script>-node

查看:51
本文介绍了从html< script> -node运行Java代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人告诉我代码

<script>
    alert(java.lang.System.getProperty("java.version"));
</script>

应该警告浏览器中安装的Java版本.

should alert the java version installed in the browser.

但是当我运行代码时,我得到 Uncaught ReferenceError:未定义Java .

But when I run the code, I get Uncaught ReferenceError: java is not defined.

我在Google Chrome 15中对其进行了测试,并且确定已安装Java.我每天都运行很多小程序.

I tested it in Google Chrome 15, and I am sure that i have java installed. I run a lot of applets daily.

代码是否有效?如果可以,该如何运行?

Is the code valid, and if so, what can I do to make it run?

更一般地说,是否可以在< script> 标记内运行任意Java代码?(注意:我知道Java和JavaScript是不同的语言.)

More generally, is it possible to run arbitrary Java code within <script> tags? (Note: I know that Java and JavaScript are different languages.)

推荐答案

您无法在脚本中运行类似的Java代码.但是,还有其他获取Java版本的方法.例如,查看此页面的源代码,您可以看到如何列出所有浏览器插件.您可能会在所有这一切中找到所需的内容(即Java版本).

You can't run Java code like that in your script. But there are other ways of getting the Java version. For example looking at the source code of this page, you can see how to list all the browser plugins. You can probably find what you need (ie java version) in all this.

这篇关于从html&lt; script&gt; -node运行Java代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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