Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert JavaScript to Java [closed]

Is there a good way to convert JavaScript to Java?

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

like image 806
user1231111 Avatar asked Apr 29 '12 07:04

user1231111


1 Answers

No, you can't.

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

From Wikipedia:

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.

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.

like image 194
Denys Séguret Avatar answered Oct 10 '22 21:10

Denys Séguret