This tool will come in handy if you’re a Java developer who needs to write web front-end from scratch
© Shutterstock / Kosev
Although its “close relative” is GWT, the difference is that “TeaVM relies on existing compilers, be it javac, kotlinc or scalac. These compilers produce bytecode (
You can use TeaVM if:
- You are a Java developer and you are going to write web front-end from scratch.
- You already have Java-based backend and want to integrate front-end code tightly into your existing development infrastructure.
- You have some Java back-end code you want to reuse in front-end.
- You are ready to rewrite your code to work with TeaVM.
SEE ALSO: Let it flow in Java
- It supports threads.
- It is fast
- It produces source maps; TeaVM IDEA plugin allows to debug code right from the IDE.
There’s also a subproject called Flavour.
What it is: a framework for writing single-paged web applications (you can use it together with your back-end code)
What it’s not: a server-side framework. You should write your back-end code using “normal” JDK like OpenJDK, Oracle JDK using your favorite frameworks.
The easiest way to run TeaVM is to use
teavm-maven-plugin. Here’s an example
<project> ... <build> <plugins> <plugin> <groupId>org.teavm</groupId> <artifactId>teavm-maven-plugin</artifactId> <version>0.5.1</version> <dependencies> <!-- This dependency is required by TeaVM to emulate subset of Java class library --> <dependency> <groupId>org.teavm</groupId> <artifactId>teavm-classlib</artifactId> <version>0.5.1</version> </dependency> </dependencies> <executions> <execution> <goals> <goal>compile</goal> </goals> <phase>process-classes</phase> <configuration> <mainClass>org.teavm.samples.HelloWorld</mainClass> <mainPageIncluded>true</mainPageIncluded> <debugInformationGenerated>true</debugInformationGenerated> <sourceMapsGenerated>true</sourceMapsGenerated> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
If you want to learn how to get started with TeaVM, here’s how.