Skip to main content

Create a project

Open in ChatGPT

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
  • Runs on

The Runs on choice decides where the app runs, with Servlet container as the default:

  • Servlet container: a WAR for Jetty, Tomcat, or another servlet container
  • Spring Boot: an executable JAR with an embedded server
  • BBjServices: an app that runs in BBjServices through BBjShip
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.

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 25.02- webforJ app with Spring Boot support.
  • webforj-bbj 26.03- webforJ app that runs in BBjServices through BBjShip.
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:

mvn

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

Keep learning

webforJ team

Need a hand?

Talk to the engineers behind webforJ about your project.

Book a call

We speak EN · DE · FR · ES