[JAVA] Probably wrong usage of Colaboratory (try Kotlin)

Introduction

The 4th series of how to use Colaboratory that is different for many minutes

This time I was asked by a junior at the company, so I would like to try Kotlin.

Past articles

-Maybe wrong usage of Colaboratory (Introduction to Go) -Maybe wrong usage of Colaboratory (introduction to now) -Maybe wrong usage of Colaboratory (using the latest nodejs)

What is Kotlin

The so-called JVM language that runs in the Java virtual machine. Java assets available. It is mainly an improvement of the bad part of Java.

Please see this page for details.

-I received an order for Android development, so it was great to use Kotlin tightly

Environmental setting

Preparing for Colaboratory

Click Google Colaboratory (https://colab.research.google.com/).

If this is your first time, a note "Welcome to Colaboratory" will open. Select "File"-"New Python 3 Notebook" from the upper left menu to open a new note.

Java installation

Java can be installed with apt. I will install the latest version of 11 because it is a big deal.

Input cell


!apt install openjdk-11-jdk
!java --version
!javac --version

Install Kotlin

Officially, you can use SDKMAN, but you cannot use shell tools in Colaboratory. (Maybe I just don't know) So, I don't use SDKMAN, I just throw it in directly.

Input cell


!curl -OL https://github.com/JetBrains/kotlin/releases/download/v1.3.21/kotlin-compiler-1.3.21.zip
!unzip kotlin-compiler-1.3.21.zip
!cp -r kotlinc/* /usr/local

Operation check

After all, the operation check is Hello World.

Input cell


%%writefile hello.kt 
fun main(args: Array<String>) {
    println("Hello, World!")
}

Input cell


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

Output cell


Hello, World!

in conclusion

I was wondering if Kotlin is for Android, but it can be replaced with Java as it is, so it seems that anything can be done. I thought I would study properly.

So, I may also do the Web Framework edition (Spring).

Recommended Posts

Probably wrong usage of Colaboratory (try Kotlin)
Let's try Zoomdata (Usage 1)
Minimal usage of Mockito