Home / TeaVM Patterns and Pitfalls     frequal.com

Make A Single Page App (SPA) With Java

Single-Page Apps are in high demand. As a Java developer, delivering an SPA is not only possible, but easy with the right toolkit. The Flavour toolkit (built on TeaVM) is powerful and full-featured. It is easy to get started thanks to a convenient maven archetype. Let's look deeper.

Starter Project

Create a new SPA project by following the TeaVM Flavour instructions here: Flavour Home Page

Simply enter the maven group id (com.example) and artifact id (test) and the project is generated. mvn clean install will build the app, and you can open it in a browser right away. The code is Java, but it runs in a browser without any plugins.

Under the Covers

Under the covers, the Java code is transpiled to javascript during the build process. The page templates from the application are bundled into the application bundle along with the business logic. Finally, the javascript is minified and packaged into a single file downloaded when the page is loaded. And there, you have it, a single-page app made entirely with Java source code!

Go Deeper

You can learn more about building apps with Flavour:
Last modified on 18 Nov 2024 by AO

Copyright © 2024 Andrew Oliver