Fork of TeaVM for compiling the EaglercraftX 1.8 WASM GC runtime, and any clients built on it
Go to file
konsoletyper 493ca64411 Extend remote debugger communication protocol for supporting messages
larger than 65536 characters (limitation of web sockets).
2014-10-05 18:25:31 +04:00
teavm-chrome-rdp Extend remote debugger communication protocol for supporting messages 2014-10-05 18:25:31 +04:00
teavm-classlib Replace old code samples with new ones 2014-10-05 15:45:44 +04:00
teavm-cli Refactoring of dependency checker in order to achieve better diagnostics 2014-09-15 17:52:55 +04:00
teavm-core Replace old code samples with new ones 2014-10-05 15:45:44 +04:00
teavm-dom Merge remote-tracking branch 'origin/canvas' 2014-10-04 17:57:40 +04:00
teavm-eclipse Extend remote debugger communication protocol for supporting messages 2014-10-05 18:25:31 +04:00
teavm-html4j Fix passing of some DukeScript tests 2014-10-04 17:54:56 +04:00
teavm-jso Fix bug in JSO that led to improper generation of functor wrappers 2014-10-05 17:12:45 +04:00
teavm-maven Minor improvements & bugfixes 2014-09-30 23:19:10 +04:00
teavm-platform Successfull build from PDE 2014-09-22 08:06:02 +04:00
teavm-samples Fix bug in JSO that led to improper generation of functor wrappers 2014-10-05 17:12:45 +04:00
.gitignore Adds root /target directory to .gitignore 2014-03-20 10:59:22 +04:00
checkstyle.xml Replace old code samples with new ones 2014-10-05 15:45:44 +04:00
LICENSE Applies apache license 2013-12-20 12:45:28 +04:00
license-regexp.txt Refactoring and bugfixes 2014-08-30 23:29:24 +04:00
NOTICE Applies apache license 2013-12-20 12:45:28 +04:00
pom.xml Replace old code samples with new ones 2014-10-05 15:45:44 +04:00
README.md Update readme 2014-10-05 16:45:44 +04:00

TeaVM

What is TeaVM?

TeaVM is an ahead-of-time translator from Java bytecode to JVM. 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.

How to use

There are several options of using TeaVM. One is the Maven build. First, you write your code as if it were an ordinary Java application:

package org.teavm.samples;

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Second, you include the following plugin in your pom.xml build section:

    <plugin>
      <groupId>org.teavm</groupId>
      <artifactId>teavm-maven-plugin</artifactId>
      <version>0.2</version>
      <dependencies>
        <dependency>
          <groupId>org.teavm</groupId>
          <artifactId>teavm-classlib</artifactId>
          <version>0.2</version>
        </dependency>
      </dependencies>
      <executions>
        <execution>
          <id>generate-javascript</id>
          <goals>
            <goal>build-javascript</goal>
          </goals>
          <phase>process-classes</phase>
          <configuration>
            <minifying>true</minifying>
            <mainClass>org.teavm.samples.HelloWorld</mainClass>
            <mainPageIncluded>true</mainPageIncluded>
          </configuration>
        </execution>
      </executions>
    </plugin>

Now you can execute mvn clean package and get the generated JavaScript files in target/javascript folder. Just open target/javascript/main.html page in your browser, open developer's console and press Refresh and see what happen.

There is also the teavm-samples module, containing examples of TeaVM-based projects.

DukeScript

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, TeaVM also provides support for running DukeScript applications, using teavm-html4j plugin.

Live examples

Thanks to Jaroslav Tulach, author of DukeScript, we have several DukeScript example applications. One is the minesweeper game. You can try its TeaVM-compiled version here, and then take a look at source code and HTML page.

Another example is avaialble here. It uses GraphHopper to build route in browser. Unlike original GraphHopper example it works completely in browser instead of querying server. Thanks to Peter Karich.