Ben Chuanlong Du's Blog

It is never too late to learn.

Ways to To Run a Kotlin JAR

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

If you generate a uber JAR, then you can directly using the java command to run the JAR file without specifying additional Kotlin runtime/stdlib JAR.

https://stackoverflow.com/questions/9355690 …

Using Kotlin With Gradle

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

https://kotlinlang.org/docs/reference/using-gradle.html

https://github.com/Kotlin/kotlin-examples/tree/master/gradle/hello-world

Understand System.identityHashCode in Java

Tips and Traps

  1. You cannot get the address of an object in Java (without hacking). System.identityHashCode(obj) is the next best thing you can have. This trick (combined with the timestamp) is used to generate default seed for random number generators in Java.

Java IO

public static Stream\<String> java.nio.file.Files.lines

public static List\<String> java.nio.file.Files.readAllLines

Read all lines from a file. Bytes from the file are decoded into characters using the UTF-8 charset. Notice that this method returns a List of Strings, which is different from the method java.nio.file.Files.lines (who returns a Stream of Strings).