diff --git a/README.md b/README.md index 2173a4bc9..2ddec942b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,66 @@ But there is something more: loop invariant motion and many other; * implementation of subset of core Java library; +How to use +---------- + +There are some options of using TeaVM. One is the maven build. First, you write your code as if it were an +ordinary Java project: + + package org.teavm.samples; + + public class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello, world!"); + } + } + +Second, you include the following dependency in your `pom.xml`: + + + org.teavm + teavm-classlib + 0.0.1-SNAPSHOT + provided + + +Third, you add `teavm-maven-plugin` in your build configuration: + + + org.teavm + teavm-maven-plugin + 0.0.1-SNAPSHOT + + + generate-javascript + + build-javascript + + process-classes + + true + org.teavm.samples.HelloWorld + + + + + +Now you can execute `mvn clean package` and get the generated JavaScript file `target/javascript/classes.js`. +It contains the `main` global function, which you may call. In the general case you should provide +an HTML page, which includes both of +[runtime.js](https://github.com/konsoletyper/teavm/blob/master/teavm-core/src/main/resources/org/teavm/javascript/runtime.js) +and `classes.js` files and calls `main` function in some condition. Here is an example: + + + + +