Skip to main content

Getting Started

This article outlines the steps to create a new webforJ app using webforJ archetypes. Archetypes provide pre-configured project structures and starter code so you can get a project up and running quickly. To create a new webforJ app from an archetype, you can use startforJ or the command line.

Prerequisites

Before you begin, review the necessary prerequisites for setting up and using webforJ.

Using startforJ

The simplest way to create a new webforJ app is startforJ, which generates a minimal starter project based on a chosen webforJ archetype. This starter project includes all required dependencies, configuration files, and a pre-made layout, so you can start building on it right away.

Customizing with startforJ

When you create an app with startforJ, you can customize it by providing the following information:

  • Basic project metadata (App Name, Group ID, Artifact ID)
  • webforJ version and Java version
  • Theme Color and Icon
  • Archetype
  • Flavor

There are two flavor options to choose from with "webforJ Only" being the default:

  • webforJ Only: Standard webforJ app
  • webforJ + Spring Boot: webforJ app with Spring Boot support
Spring Boot support

Spring Boot flavor is only available in webforJ version 25.02 and higher. If you select this option, make sure to choose a compatible version.

Available Archetypes

webforJ comes with several predefined archetypes to help you get started quickly. For a complete list of available archetypes, see the archetypes catalog.

Using this information, startforJ will create a basic project from your chosen archetype with your chosen customizations. You can choose to download your project as a ZIP file or publish it directly to GitHub.

Once you have downloaded your project, open the project folder in your IDE and move on to running the app.

Using the command line

If you prefer to use the command line, you can generate a project directly using the Maven archetype:

To create and scaffold a new hello-world project, follow these steps:

  1. Navigate to the proper directory: Open a terminal and move to the folder where you want to create your new project.
  2. Run the archetype:generate command: Use the Maven command below, and customize the groupId, artifactId, and version as needed for your project.
mvn -B archetype:generate \
-DarchetypeGroupId=com.webforj \
-DarchetypeArtifactId=webforj-archetype-hello-world \
-DarchetypeVersion=LATEST \
-DgroupId=org.example \
-DartifactId=my-app \
-Dversion=1.0-SNAPSHOT \
-Dflavor=webforj \
-DappName=MyApp
ArgumentExplanation
archetypeGroupIdThe group ID of the archetype is com.webforj for webforJ archetypes.
archetypeArtifactIdSpecifies the name of the archetype to use.
archetypeVersionSpecifies the version of the archetype to use. This ensures that the generated project is compatible with a specific archetype version. Using LATEST selects the most recent version available.
groupIdRepresents the namespace for the generated project. Typically structured like a Java package, such as org.example and is used to uniquely identify your organization or project domain.
artifactIdSpecifies the name of the generated project. This will be the name of the resulting artifact and the project folder.
versionDefines the version of the generated project. A common convention is MAJOR.MINOR-SNAPSHOT, like 1.0-SNAPSHOT, where SNAPSHOT denotes that the project is still in development.
flavorSelects a project flavor:
  • webforj - Standard webforJ app.
  • webforj-spring - webforJ app with Spring Boot support (requires webforJ 25.02 or higher).
appNameAn optional parameter that can be used in the generated project's POM file. Depending on the used webforJ archetype, it can be utilized as a default title for the application.

After running the command, Maven will generate the project files necessary to run the project.

Running the app

Before running your app, install the prerequisites if you haven't yet. Then, navigate to the project's root directory and run the following command:

# for standard webforj app
mvn jetty:run

# for webforj + Spring Boot
mvn spring-boot:run

Once the server is running, open your browser and go to http://localhost:8080 to view the app.

Licensing and watermark

For information on the watermark present in unlicensed projects, see Licensing and Watermark.