In this tutorial, you are going to learn how to do kotlin programming in eclipse. You will learn how to create kotlin project in eclipse.
As i mentioned earlier, you would need plugin to program in kotlin programming language. So, we will first install kotlin plugin, then, we will create first project.
Install Kotlin plugin in Eclipse
At this point of time, i am assuming that you have successfully installed eclipse in you system. If not, you can download it from Download page. It is officially recommended, by kotlin developers, to install Eclipse IDE for Java Developers bundle. You should download Eclipse Neon(4.6 or later) for proper functioning.
Now, you can install plugin in you eclipse IDE in either ways mentioned below.
1. You can install kotlin plugin from Kotlin plugin download page. You will see a install button there. Just drag and drop this button into your running eclipse window.
After that, you will be asked to confirm the selection. Just click on Confirm button.
After that, you will be asked to accept the terms and conditions. So, select the “I accept…” and click on finish button.
2.The other way to install Kotlin plugin is through eclipse IDE. Follow steps below to install it.
a. Open eclipse IDE. Go to Help => Eclipse Marketplace… menu.
b. Then, search for Kotlin plugin. Click on install button to install it.
Once eclipse is restarted, you can check whether Kotlin is installed correctly or not. Go to Window => Open Perspective… => Other. Select Kotlin and press OK. You will notice that Kotlin perspective window is opened.
If you have successfully opened Kotlin perspective window, it means you have successfully installed Kotlin plugin. Now, You can create Kotlin Application (If you are in Kotlin perspective).
Creating First Kotlin Application in Eclipse
Since we have successfully installed kotlin plugin. So, we are able to create a new kotlin project now in eclipse.
Follow the below steps to create any kotlin application in eclipse –
1. Go to File => New => Kotlin Project.
A project will be create which is ready for writing Kotlin code that targets JVM. You will notice that this is same as java project. The difference between java project and kotlin project is that kotlin project is configured with kotlin builder and kotlin runtime library. But, you can also include mix the java code and kotlin code into the kotlin project, if required. Project structure of newly created project will be as below.
our next target will to create a new kotlin file and write to print “Hello World”.
2. Select src folder and write click on it. Now, Go to New => Kotlin File and click on it.
3. Then, you will be asked to select path of the file and provide name of the file. Enter the detail and click finish. In this tutorial, i have given the file name as hello.kt. However, you can give name as per your choice.
4. Since we have a kotlin file, we can write main routine which is entry point to kotlin application. Just write below code to print “Hello World”.
5. To run the application, select the file and right click on it. Then, Run as => Kotlin Application.
6. You will get output as below.
That’s it. We have successfully created first Kotlin application in eclipse IDE.
If you have any suggestion about this post, please comment below. We are looking for someone who helps use to make our tutorial better. Also, If you want tutorials on any topic, you can mail us at email@example.com. We will try to cover the topic as soon as possible. Connect with us on Facebook, Google+, Twitter and Youtube for more updates.