Kotlin - IntelliJ Project Setup -
i want start new project kotlin jvm using intellij ide, can't configuration work. attempting follow this tutorial, , after didn't work (the "run '_defaultpackage'" option never showed up), started trying intuit supposed done without success. has happened far (repeatedly):
- i created new project, selected "kotlin - jvm" project type.
- i clicked "create..." button kotlin runtime on second page , selected "copy to: lib".
- i click "finish" , project created has 1 module same name project. there no default source file or configuration.
- i create kotlin file named "app.kt" (i've tried other names too, "main.kt"), , put following source code in:
fun main(args: array<string>){ println("hello world!") }
- i right clicked on code editor , file in left pane find "run '_defaultpackage'" option mentioned in tutorial, failed find in either.
- i create new kotlin configuration, asks put in "main class". seeing this, change code to:
public class main { fun main(args: array<string>) { println("hello world!") } }
- i edit configuration , set main class "main", , run configuration. fails error: "error running : function 'main' not found in class 'main'.
what missing?
a full answer how identify runnable class top-level main()
function, or use main()
method within class both documented in other stack overflow answer: how run kotlin classes
this covers running on command-line, within intellij (as question asks), gradle, , more.
Comments
Post a Comment