Learn Pain Less

HomeOur TeamContact
Kotlin
Kotlin Working with the Command Line Compiler
Pawneshwer Gupta
Pawneshwer Gupta
June 30, 2017
1 min

Table Of Contents

01
Kotlin Working with the Command Line Compiler
02
Download compiler
03
Creating and running a first application
Kotlin Working with the Command Line Compiler

Kotlin Working with the Command Line Compiler

In this tutorial we will create hello world application in kotlin using command line compiler from Github release page.

Download compiler

Every release ships with a standalone version of the compiler. we will download the newest version

Manual Install

Unzip the standalone compiler into a directory and optionally add the bin directory to the system path. The bin directory contains the scripts needed to compile and run Kotlin on Windows, OS X and Linux.

SDKMAN!

An easier way to install Kotlin on UNIX based systems such as OS X, Linux, Cygwin, FreeBSD and Solaris is by using SDKMAN!. Simply run the following in a terminal and follow any instructions:

$ curl -s https://get.sdkman.io | bash

Next open a new terminal and install Kotlin with:

$ sdk install kotlin

Homebrew

Alternatively, on OS X you can install the compiler via Homebrew.

$ brew update
$ brew install kotlin

Snap package

If you’re on Ubuntu 16.04 or later, you can install the compiler from the command line:

$ sudo snap install --classic kotlin

Creating and running a first application

  1. Create a simple application in Kotlin that displays Hello, World!. Using our favorite editor, we create a new file called hello.kt with the following:
fun main(args: Array<String>) {
println("Hello, World!")
}
  1. Compile the application using the Kotlin compiler

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

The -d option indicates the output path for generated class files which may be either a directory or a .jar file. The -include-runtime option makes the resulting .jar file self-contained and runnable by including the Kotlin runtime library in it. If you want to see all available options run

$ kotlinc -help

  1. Run the application.

$ java -jar hello.jar

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Tags

startCLIIDE

Share


Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.

Expertise

Python
Flutter
Laravel
NodeJS

Social Media

Related Posts

Basic Syntax of Kotlin Programming Language
Basic Syntax of Kotlin Programming Language
June 30, 2017
1 min
Working with Files, Folders java
Java
Working with Files, Folders java
March 25, 2015
1 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media