Kotin part-01

kotlin logo

What is Kotlin

Kotlin is a general-purpose, statically typed, and open-source programming language. It runs on JVM and can be used anywhere Java is used today. It can be used to develop Android apps, server-side apps and much more.

Kotlin Environment Setup (Command line)

Since Kotlin runs on JVM, it is necessary to install JDK and setup the JDK and JRE path in local system environment variable.

Setup Kotlin for Command Line

To setup Kotlin for command line, we need to go through following steps:

  1. Download the Kotlin Compiler from GitHub Releases https://github.com/JetBrains/kotlin/releases/tag/v1.2.21 .

2. Extract downloaded zip in any of system location (in my case it is in C drive).

3. Copy the path up to bin directory of kotlinc.

4. Open Computer properties and click Environment variables.

5. Click on edit path

6. Past the path of kotlinc bin directory in variable value.

we finished setup kotlin for cmd just now. And next we do a small program in that……..

To write Kotlin program, we can use any text editor like: Notepad++. Put the following code into any text file and save.

Save the file with name hello.kt, .kt extension is used for Kotlin file.

fun main(args:Array<String>){

println(“Hello,World!”)

}

// hello.kt — ->saving name

Compile Kotlin File

Open command prompt and go to directory location where file is stored. Compile hello.kt file with following command.

kotlinc hello.kt -include-runtime -d hello.jar

Run Kotlin File

To run the Kotlin .jar (hello.jar) file run the following command.

java -jar hello.jar

after that click enter. we will get the output — -Hello,World! — -

wait for the part-02(Kotlin Environment Setup (IDE))

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store