title: Trying to run Kotlin script in IntelliJ IDEA
body: <p>I am learning Kotlin by doing Kotlin Koans int IntelliJ EduKotlin plugin (<a href="https://plugins.jetbrains.com/plugin/8186" rel="noreferrer">https://plugins.jetbrains.com/plugin/8186</a>). While doing tasks and running them im this plugin is working, I am not able to create new Kotlin script and run it <strong>without</strong> this plugin.</p>
  
  <p>Sample code in a file named <strong>Hello.kt</strong>:</p>
  
  <pre><code>fun hello() : String {
      return "ok"
  }
  </code></pre>
  
  <p>Then I create new run configuration derived from 'Kotlin script', set 'Working directory' to ProjectName/src folder (or ProjectName folder, same result) and IDE shows me a 'Could not find script file: Hello.kt' warning as in the screen below:</p>
  
  <p><a href="https://i.stack.imgur.com/kSOHb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kSOHb.png" alt="enter image description here"></a></p>
  
  <p>And indeed, while trying to run script I got following stacktrace:</p>
  
  <pre><code>"C:\Program Files\Java\jdk1.8.0_74\bin\java" -Dfile.encoding=windows-1250 -classpath C:\Users\myUser\.IdeaIC2016\config\plugins\Kotlin\kotlinc\lib\kotlin-compiler.jar;C:\Users\myUser\.IdeaIC2016\config\plugins\Kotlin\kotlinc\lib\kotlin-reflect.jar;C:\Users\myUser\.IdeaIC2016\config\plugins\Kotlin\kotlinc\lib\kotlin-runtime.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -script Hello.kt
  exception: java.lang.RuntimeException: Failed to evaluate script: kotlin.KotlinNullPointerException
  at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileScript(KotlinToJVMBytecodeCompiler.kt:263)
  at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileAndExecuteScript(KotlinToJVMBytecodeCompiler.kt:212)
  at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:181)
  at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:49)
  at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:181)
  at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:138)
  at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:57)
  at org.jetbrains.kotlin.cli.common.CLICompiler.doMainNoExit(CLICompiler.java:248)
  at org.jetbrains.kotlin.cli.common.CLICompiler.doMain(CLICompiler.java:238)
  at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:248)
  at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
  Caused by: kotlin.KotlinNullPointerException
  at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileScript(KotlinToJVMBytecodeCompiler.kt:475)
  ... 10 more
  
  
  Process finished with exit code 2
  </code></pre>
  
  <p>What more, the hello method is marked as never used. However, when I change file extension from .kt to .ktscript, then this method is marked as used, and the output from running code is following:</p>
  
  <pre><code>"C:\Program Files\Java\jdk1.8.0_74\bin\java" -Dfile.encoding=windows-1250 -classpath C:\Users\myUser\.IdeaIC2016\config\plugins\Kotlin\kotlinc\lib\kotlin-compiler.jar;C:\Users\myUser\.IdeaIC2016\config\plugins\Kotlin\kotlinc\lib\kotlin-reflect.jar;C:\Users\myUser\.IdeaIC2016\config\plugins\Kotlin\kotlinc\lib\kotlin-runtime.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -script Hello.kt
  </code></pre>
  
  <p>error: source file or directory not found: Hello.kt</p>
  
  <pre><code>Process finished with exit code 1
  </code></pre>
  
  <p>So my question is: what am I missing when trying to create and run Kotlin code in a standalone Kotlin script in IntelliJ?</p>