teavm/README.md

79 lines
3.5 KiB
Markdown
Raw Normal View History

2013-12-12 19:18:15 +08:00
TeaVM
=====
2015-10-10 18:38:55 +08:00
[![Build Status](https://travis-ci.org/konsoletyper/teavm.svg?branch=master)](https://travis-ci.org/konsoletyper/teavm)
2013-12-12 19:18:15 +08:00
What is TeaVM?
2013-12-12 19:35:18 +08:00
--------------
2013-12-12 19:18:15 +08:00
2014-11-22 15:48:33 +08:00
TeaVM is an ahead-of-time translator from Java bytecode to JavaScript.
2014-10-05 20:45:44 +08:00
It can be compared with GWT, however TeaVM does not require source code of your application and
all required libraries.
You can use TeaVM for building applications for the browser, due to the following features:
* per-method dependency analyzer, that determines a set of methods that are really needed
to run your application, so TeaVM won't translate whole JAR files;
* fast JavaScript; for now it is almost as fast as the JavaScript, generated by GWT;
* Java class library emulation;
* integration with Maven and Eclipse;
* generation of source maps;
* debugger;
* interoperation with JavaScript libraries together with the set of predefined browser interfaces.
2013-12-12 19:18:15 +08:00
Quick start
-----------
There are several options of using TeaVM. One is the Maven build.
The easiest way to create a new TeaVM project is to type in the command line:
2014-10-07 17:56:54 +08:00
mvn -DarchetypeCatalog=local \
-DarchetypeGroupId=org.teavm \
-DarchetypeArtifactId=teavm-maven-webapp \
2015-12-31 14:34:58 +08:00
-DarchetypeVersion=0.4.3 archetype:generate
Now you can execute `mvn clean package` and get the generated `war` file.
Deploy this `war` in Tomcat or another container, or simply unzip it and open the `index.html` page.
2014-10-06 21:55:46 +08:00
It is much easier to develop TeaVM applications using Eclipse.
2014-10-06 21:56:50 +08:00
If you prefer Eclipse, please read [this tutorial](https://github.com/konsoletyper/teavm/wiki/Eclipse-tutorial).
2014-10-06 21:55:46 +08:00
2015-10-23 21:42:45 +08:00
To learn TeaVM deeper, you take a look at the [samples](samples) module,
2014-10-09 21:36:44 +08:00
containing examples of TeaVM-based projects.
Also you can read [project's wiki](https://github.com/konsoletyper/teavm/wiki/).
DukeScript
----------
[DukeScript](http://wiki.apidesign.org/wiki/DukeScript) is a set of APIs that allows Java applications
easily talk to JavaScript environment to (usually) animate an HTML page. While DukeScript has its own
implementation of JVM, called [Bck2Brwsr](http://wiki.apidesign.org/wiki/Bck2Brwsr), TeaVM also provides
support for running DukeScript applications, using [teavm-html4j](teavm-html4j) plugin.
2014-05-05 17:02:13 +08:00
Live examples
-------------
2014-10-07 17:56:54 +08:00
Compare the speed of JavaScript produced by TeaVM and GWT here: http://teavm.org/live-examples/jbox2d-benchmark/
2014-10-15 01:22:01 +08:00
Play [Geobot](http://teavm.org/live-examples/geobot/), a little physics-based puzzle game.
Thanks to [joan789](http://joan789.deviantart.com/) for her great artwork!
Thanks to [Jaroslav Tulach](http://wiki.apidesign.org/wiki/User:JaroslavTulach), author of DukeScript, we have several
DukeScript example applications. One is the minesweeper game.
You can try its TeaVM-compiled version [here](http://xelfi.cz/minesweeper/teavm/), and then take a look at
[source code](http://source.apidesign.org/hg/html~demo/file/4dce5ea7e13a/minesweeper/src/main/java/org/apidesign/demo/minesweeper/MinesModel.java)
and [HTML page](http://source.apidesign.org/hg/html~demo/file/4dce5ea7e13a/minesweeper/src/main/webapp/pages/index.html).
2015-07-09 09:47:55 +08:00
Another example is available [here](http://graphhopper.com/teavm/).
2014-05-05 17:02:13 +08:00
It uses [GraphHopper](https://github.com/graphhopper/graphhopper/) to build route in browser.
Unlike original GraphHopper example it works completely in browser instead of querying server.
2014-10-07 17:56:54 +08:00
Thanks to [Peter Karich](https://github.com/karussell).
2014-10-20 04:31:28 +08:00
Feedback
--------
Ask your questions by email: info@teavm.org. Also you can report issues on a project's [issue tracker](https://github.com/konsoletyper/teavm/issues).