Over a million developers have joined DZone.

With Kotlin to the Clouds (AWS Beanstalk, Oracle ACCS)

DZone's Guide to

With Kotlin to the Clouds (AWS Beanstalk, Oracle ACCS)

Loving Kotlin? Well, let's see what it takes to deploy Kotlin to a couple of different cloud services, namely Oracle ACCS and AWS Beanstalk.

· Cloud Zone ·
Free Resource

Learn how to migrate and modernize stateless applications and run them in a Kubernetes cluster.

This posting is based on a quick customer demo that I did the other week. It demonstrates running Kotlin code in different public clouds. To be more precise: We use Kotlin together with Spring Boot to create a somehow minimalistic REST-like application that runs on multiple load balanced instances on AWS Beanstalk or Oracle ACCS.


Kotlin is one of the upcoming, trendy JVM-based languages. Its syntax is close to Java, but just sometimes more convenient. The language is backed by two industry giants: Pivotal announced support for Spring and Google officially supports Android development with Kotlin.

The Kotlin language follows Java coding conventions, but makes the semicolon mostly optional (great!) and adds null-pointer safety (you never had a problem with this in Java, did you?) and string interpolation on top of that. Although Kotlin packages are the same as in Java in reverse order, in Kotlin, package names don't have to match the folder structure (great!). Interestingly enough, most Kotlin control structures are expressions.

Spring Boot

We will use Kotlin together with Spring Boot in this post.

Project Creation

For the purpose of this demo, we will create the smallest possible application that is still helpful to learn about the synergy of Kotlin, Spring Boot, and the cloud. To get started, we create a maven project for Spring Boot with the spring.io initializer.

The project will contain an empty Spring Boot application and the maven POM file, amongst others.

Add a Controller

To get some meaningful output, we will add another Kotlin class: A controller with three functions.  

  1. The hello(World) function that simply echoes a name.
  2. A func that shows how to access java.util.Date from Java and returns the time.
  3. An info func that show a bit of load balancing magic when deployed on ACCS.

Build the Project

We can build the project with a mvn package from the command line (or from the IDE, as shown in the webcast down below).

IDE Support for Kotlin

Being developed by JetBrains, IntelliJ offers great support for Kotlin. In the webcast, I simply use Netbeans.

Kotlin in the Clouds

This little demo is more real life than you might think. I will show you how to run Kotlin in two different clouds. These days, I usually see multiple clouds with my customers. Simply choose the one you like most.


ACCS is an Oracle Public Cloud PaaS service that provides several language runtimes. ACCS is based on Docker containers, but don't worry, you won't see any of them. With ACCS, you can easily deploy Java, Java EE, as well as Python, Ruby, Node.js, and even Go code. Also, it supports spinning up multiple instances with load balancing.

Deploying a .jar file on ACCS is as straightforward as it gets:

  1. Zip it.
  2. Upload it.
  3. Run it.

However, there is one more thing: To successfully run the .jar file, we need to add a manifest.json file that contains the exact command of how the JAR file will be started in the Java container. It should be obvious to all watching the webcast. Check my other posting to learn about ACCS and Java EE.


The AWS Beanstalk deployment isn't more complicated than the ACCS one. Actually, even the manifest.json file can be omitted. Beanstalk implicitly understands how to run a .jar file (which, of course, is easy in most cases: java -jar demo.jar). So all you need to do is upload to Beanstalk. However, with Beanstalk, we have to make sure to include a SERVER_PORT variable and set its value to 5000. This is required since Beanstalk is internally listening to port 5000, but Spring Boot uses 8080.


I created a webcast for you with all the details.


Some additional resources that you might find useful:

  1. Kotlin language
  2. Try Kotlin online
  3. Spring Initializr
  4. Get started with ACCS
  5. AWS Beanstalk
  6. Code for kotlin2cloud on GitHub
  7. Webcast Kotlin on Beanstalk or ACCS 

Join us in exploring application and infrastructure changes required for running scalable, observable, and portable apps on Kubernetes.

kotlin ,cloud ,oracle accs ,aws beanstalk ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}