将JavaScript转换为Java [英] Convert JavaScript to Java

查看:765
本文介绍了将JavaScript转换为Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种很好的方法可以将JavaScript转换为Java?

Is there a good way to convert JavaScript to Java?

我有一个需要转换为Java的JavaScript文件。它是用JavaScript编写的日历组件。

I have a JavaScript file which needs to be converted to Java. It's a calendar component written in JavaScript.

推荐答案

不,你不能。

类似的名字很不幸,但JavaScript和Java是完全不同的语言。

The similar names are unfortunate but JavaScript and Java are totally different languages.

来自 Wikipedia


JavaScript使用受C语言影响的语法.JavaScript副本来自Java的许多
名称和命名约定,但这两种语言是
,否则无关,并且具有非常不同的语义。 JavaScript中的关键设计
原则来自Self和Scheme
编程语言。

JavaScript uses syntax influenced by that of C. JavaScript copies many names and naming conventions from Java, but the two languages are otherwise unrelated and have very different semantics. The key design principles within JavaScript are taken from the Self and Scheme programming languages.

更准确地说:当然可以。但这涉及在java程序中编写或合并JS引擎,二进制代码或某种解释器。一个完整的转换器可能是可能的,但并不容易,特别是在这个方向,当然还没有。

More precisely: of course you can. But that involves writing or incorporating a JS engine, binary code, or an interpretor of some sort in your java program. A complete transpiler is probably possible but wouldn't be easy, especially in this direction, and of course hasn't been made.

这篇关于将JavaScript转换为Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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