简体   繁体   English

使用GWT将Java编译为Javascript库

[英]Compile Java to a Javascript Library Using GWT


In my project I need to take Java code and compile it to a Javascript library so it may be used in my web application. 在我的项目中,我需要获取Java代码并将其编译为Javascript库,以便可以在我的Web应用程序中使用它。
I'm thinking of using GWT, but I don't need all that it offers. 我正在考虑使用GWT,但我不需要它提供的所有功能。 I just need a simple command line utility that can take Java code and emit Javascript. 我只需要一个简单的命令行实用程序,即可接收Java代码并发出Javascript。
I haven't used GWT before and I'm getting a little lost in all of the information out there about building a complete web application. 我以前从未使用过GWT,但是在构建完整的Web应用程序的所有信息中,我却有些迷失。
The GWT Exporter project seems interesting, but I can't figure out how to use in my use case. GWT Exporter项目似乎很有趣,但是我无法弄清楚如何在用例中使用它。
Any help is appreciated 任何帮助表示赞赏

ST-JS may be what you're looking for. ST-JS可能就是您想要的。 In a nutshell, it's a way to compile a subset of Java into JavaScript so your Java and JavaScript code use the same API. 简而言之,这是将Java子集编译为JavaScript的一种方法,因此您的Java和JavaScript代码使用相同的API。 The Java side of the tool even emulates jQuery (so you can use $(...) in Java code with code completion and type safety). 该工具的Java端甚至可以模拟jQuery(因此,您可以在Java代码中使用$(...)来实现代码完成和类型安全。

This code can't be executed in the Java VM. 该代码无法在Java VM中执行。 It's mainly a type safe way to write JavaScript code. 这主要是一种编写JavaScript代码的类型安全方式。

You can find more details in my blog post: http://blog.pdark.de/2013/10/24/jazoon-2013-stjs-managing-javascript-application-complexity/ 您可以在我的博客文章中找到更多详细信息: http : //blog.pdark.de/2013/10/24/jazoon-2013-stjs-managing-javascript-application-complexity/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM