Create a project
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.
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
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:
- Navigate to the proper directory: Open a terminal and move to the folder where you want to create your new project.
- Run the archetype:generate command: Use the Maven command below, and customize the groupId, artifactId, and version as needed for your project.
- Bash/Zsh
- PowerShell
- Command Prompt
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
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"
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"
| Argument | Explanation |
|---|---|
archetypeGroupId | The group ID of the archetype is com.webforj for webforJ archetypes. |
archetypeArtifactId | Specifies the name of the archetype to use. |
archetypeVersion | Specifies 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. |
groupId | Represents 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. |
artifactId | Specifies the name of the generated project. This will be the name of the resulting artifact and the project folder. |
version | Defines 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. |
flavor | Selects a project flavor: |
appName | An 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
ArticleWho Uses webforJ? Customer Stories From Real Projects
ArticleStarting a New Java Project: The Decisions That Shape the Stack
ArticleWhat is the easiest Java web framework? A checklist
ArticleHow to build a web app in Java, step by step
ArticleRapid application development in Java without low-code
ArticleJava web app tutorial for beginners: build your first app