Java
To use our example repositories, you must create a Sevalla account. This is an example of how to set up a Java application to deploy on Sevalla’s Application Hosting services from a GitHub repository.
- In Sevalla, click Applications > Add application > select Git repository > Public repository, and complete as follows:
- Repository URL: https://github.com/kinsta/hello-world-java
- Branch: main
- Enter a Name, choose a Location, choose a pod size within Resources, and click Create & deploy.
During deployment, Sevalla 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.
Java Hello World page after successful installation.
Prefer to watch the video version?
Web server setup
Port
Sevalla 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.
Start command
When you deploy an application and include a Procfile in the repository, Sevalla 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