Deploying a Java app
If you're developing a server-side application, you likely only need to do three things after deploying your app:
- Configure your app (or server settings) to force HTTPS.
- Configure your app to read your Okta settings (for example, issuer, client ID, and client secret) from environment variables or a secrets provider (like HashiCorp Vault).
- Modify your Okta app to have sign-in and sign-out redirect URIs that match your production app.
Java applications typically build into a WAR or a JAR for production.
If you deploy your application as a WAR, it's possible you have a context path. If you do, add this path to your Sign-in redirect URI and your Sign-out redirect URI for your Okta app.
JAR-based Java apps usually don't have a context, and if you start them locally, they are available at
The easiest way to deploy your Java app to production with Okta is to use Heroku. We provide an Okta Heroku Add-on(opens new window) that auto-provisions an Okta org for you and adds the appropriate applications to it.
To begin, install the Heroku CLI(opens new window) and run
You can deploy your Java application to Heroku in five steps:
Add the Git remote that's created as a remote for your project.
heroku addons:create okta.
Procfile that sets the
PORT and your Okta configuration.
Commit your changes and run
git push heroku master.
If your branch isn't named
Tip: If you want to use a different version of Java, create a
system.properties and add
java.runtime.version=11 (or another version) to it.
You won't be able to sign in to your application until you add your Heroku app's URLs to your Sign-in redirect URIs and Sign-out redirect URIs on Okta.
For more information, see Deploy a Secure Spring Boot App to Heroku(opens new window) .
You can enforce the use of HTTPS when your app is running on Heroku by adding the following configuration to your security configuration.
You can package your Java application with Docker, too. See Angular + Docker with a Big Hug from Spring Boot(opens new window) for a blog post that details how. Specifically, see the Dockerize Angular + Spring Boot with Jib(opens new window) section.