问题描述
我有一个用Java维护的项目,主要作为applet运行。我发现Applet对于浏览器游戏来说简直不切实际且危险,因为大多数最终用户都不相信任何applet,因为它在浏览器中运行(这也是applet如此可怕的声誉。)
I have a project I maintain in Java that runs primarily as an applet. I am finding that Applets are simply unpractical and dangerous for browser games as most end-users ignorantly trust any applet because it runs in the browser (this is also what gives applets such a terrible reputation.)
我想将我的Java项目编译为JavaScript并使用HTML5进行渲染。虽然我可以看到一些问题......
I want to compile my Java project to JavaScript and use HTML5 for rendering. There are a couple problems I can see with this though...
-
将Java反射转换为JavaScript是否可行?我使用Java的ScriptEngine模块在引擎中运行脚本。
Would it be feasible to translate Java reflection to JavaScript? I use Java's ScriptEngine module to run scripts in the engine.
这种编译思想的可扩展性如何。我有几个纯Java依赖项,也需要编译为javascript(特别是Vorbis Audio SPI。)代码库编译为~300kb(不确定是否有助于衡量大小)
How scalable is this idea of compiling to JavaScript. I have several pure Java dependencies that would also need to be compile to javascript (Specifically an Vorbis Audio SPI.) The code-base compiles to ~300kb (not sure if that helps gauge the size)
这个过程会遇到哪些其他可能的限制?
What are some other likely restrictions to encounter with this process?
谢谢。
推荐答案
嗯...... GWT将java编译为JavaScript,你可以使用它。
Hmm.. GWT compiles java to JavaScript you can use it.
另一种可能性是使用
或者只是暴露REST服务并使用它创建一个HTML5 Web应用程序。
Or just expose REST services and create an HTML5 web application using it.
编辑:BTW在论坛中搜索。我发现了一些像这样的问题。
BTW search in the forum. I found some questions like this one.
这篇关于将Java转换为JavaScript项目有多可行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!