weranj.blogg.se

Java to kotlin
Java to kotlin












Then I created a kotlin folder in src/main and src/test along with the java folder and copied the packages to kotlin folder. This was perhaps an ambitious choice, and I regretted much during the course of conversion from Java to Kotlin that why did I choose this option, but at the end of the day this was perhaps the better choice. I decided to go with the option no 2 and go for the kill. I found this article on Kotlin’s website. Before this, I had to setup my application, which is a Maven based Spring Boot 1.5 application running Java 8, with adequate Maven dependencies related to Kotlin. I was so committed that I said to myself, lets roll up the sleeves and do it. But soon I realized that I have 100+ of such files (including tests) to convert 😱.

  • IDE will show the following prompt, click Yes and it will convert the code.
  • java to kotlin

  • Copy the code from Java file to Kotlin file.
  • Create a Kotlin file for every Java file.
  • Since I use IntelliJ, the approach was following Luckily there were few ways available, out of those I selected one that seemed easily doable. The adventure begin with few google searches for how to auto convert Java to Kotlin, so that I do not have to learn everything in Kotlin upfront. During the course of action, there were numerous wow! and oh no! moments. Took several hours to pass the build and tests, and then few hours to have the application tested by running it.

    java to kotlin

    I got excited immediately, and that’s probably a bit workaholic or you may say that I am passionate to work and cannot live long without actually getting my hands dirty with keyboard 🙃Īnyways, given that I had never worked on Kotlin before this day, I was not sure if I would succeed. Waking up in the morning on Friday, a weird idea came to my mind, an idea to convert an existing application from Java to Kotlin. It was Friday May 01, 2020, the Labor Day holiday in Pakistan 🇵🇰Ī day before I had thought to not work on any software related stuff to give myself a break for a long weekend spanning Friday, Saturday and Sunday, so that I can re-energize myself for another Working from home week. I have migrated a Java Spring Boot Project to Kotlin without any prior experience on Kotlin














    Java to kotlin