Java web app tutorial for beginners: build your first app

You know some Java, you have written console programs or a few classes, and now you want to see something running in a browser. Most guides at this point throw HTML, JavaScript, a template engine and a build pipeline at you before the first page shows up.
This java web app tutorial for beginners takes a shorter path. With webforJ, a full-stack Java framework, you build the page in Java, generate a working project in a minute and run it with one Maven command. By the end you will have a first Java web app on screen, a button that reacts to clicks, and a clear idea of where to go next.
What you need before you start
Two tools are enough:
- A JDK, version 21 or higher.
- Maven, to build and run the project.
Run java -version and mvn -v in a terminal to check both. If one is missing, the prerequisites page lists where to download each and how to install them. Any editor with Java support works, such as IntelliJ IDEA or Visual Studio Code.
You do not need to know HTML, CSS or JavaScript to follow along.
Step 1: Generate the project
The quickest way to make a website with Java is to let a generator create the skeleton. Open startforJ in your browser and fill in a few fields:
- Give the app a name, a group ID and an artifact ID.
- Pick the HelloWorld archetype. It is the starter made for beginners.
- Leave Runs on at its default, the servlet container.
- Download the ZIP and open the folder in your editor.
Prefer the terminal? The getting started page also shows the Maven command that generates the same project. The HelloWorld archetype page describes what the starter contains.
