This is an example of how to set up a Java application to deploy on Kinsta’s Application Hosting services from a GitHub repository.
- Kinsta’s quick start templates are stored and managed in GitHub; therefore, you need a GitHub account to access them.
- You need to create a MyKinsta account to deploy the application.
Deploy a Java Application
- Log in to GitHub and create a new repository from this template (Use this template > Create a new repository): Kinsta – Hello World – Java.
- In MyKinsta, click Applications > Add application > select GitHub, click Connect git provider > Authorize, and log in to your GitHub account.
- Choose the Hello World Java repository and a Data center location. Leave all other settings as default and click Continue on each step.
- On the Summary step, click Create application.
During deployment, Kinsta automatically detects the Start command for the web process from the Procfile in the repository and installs dependencies defined in your pom.xml file. You must ensure your main class is defined in the pom.xml file. The app is available as soon as the deployment finishes, and a Hello World page loads at your application’s URL.
Prefer to watch the video version?
Web Server Setup
Kinsta automatically sets the
PORT environment variable. You do not need to define it or hard-code it into the application. Use
System.getenv("PORT") in your code when referring to the server port.
When you deploy an application and include a Procfile in the repository, Kinsta automatically creates a web process based on the Procfile in the root of the repository. Use this command in your Procfile to run your web server:
web: java -jar target/kinsta-java-hello-world-1.0-SNAPSHOT.jar