Kotlin hello world


(Thufir) #1

first kotlin attempt:

thufir@dur:~/kotlin$ 
thufir@dur:~/kotlin$ kotlinc Main.kt -include-runtime -d hello.jar
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.text.StringFactory to constructor java.lang.String(char[],boolean)
WARNING: Please consider reporting this to the maintainers of com.intellij.util.text.StringFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Main.kt:5:14: warning: parameter 'args' is never used
    fun main(args: Array<String>) {
             ^
thufir@dur:~/kotlin$ ll
total 892
drwxr-xr-x  2 thufir thufir   4096 Oct 27 06:48 ./
drwx------ 46 thufir thufir  16384 Oct 27 06:47 ../
-rw-r--r--  1 thufir thufir 870309 Oct 27 06:48 hello.jar
-rw-r--r--  1 thufir thufir     92 Oct 27 06:47 Main.kt
thufir@dur:~/kotlin$ 
thufir@dur:~/kotlin$ 
thufir@dur:~/kotlin$ java -jar hello.jar 
no main manifest attribute, in hello.jar
thufir@dur:~/kotlin$ 
thufir@dur:~/kotlin$ 
thufir@dur:~/kotlin$ cat Main.kt 
class Main {



    fun main(args: Array<String>) {
        println("Hello, world!")
    }
}thufir@dur:~/kotlin$ 
thufir@dur:~/kotlin$ 

So, obviously gradle is needed! I can muck around with shadowJar and runShadow but what’s the Kotlin equivalent?

From what I’ve read, start with gradle init --type java-application and then add the kotlin plugin to the gradle build file. That’s fine, but, what should the Gradle build file look like, approximately? Hello world pls.