2

I was following Kotlin Tutorial

So I went to notepad++ and created

hello.kt

Contents of

hello.kt



fun main() {
    println("Hello, World!")
}

Next I opened cmd and typed:

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

This is the output:

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by com.intellij.util.containers.Unsafe
WARNING: Please consider reporting this to the maintainers of class com.intellij.util.containers.Unsafe
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
hello.kt:4:5: error: unresolved reference 'println'.
    println("Hello, World!")
    ^^^^^^^

Please note I am not working in intellij idea. I am trying to run a basic kotlin standalone app and have correctly configured the path to kotlinc bin folder of kotlin-compiler-2.2.10.zip

All the other solutions and problems posted on stackoverflow are applicable to people working in intellij idea and I am not working in intellij idea. Please help me to get up and running in Windows terminal using the kotlin compiler only. On my Windows machine, I have jdk 24

2
  • I think you can ignore all the WARNING lines.  When I try the exact same code and command on macOS (kotlinc-jvm 2.2.0 (JRE 24.0.2)), I get all those warnings — and more — but it goes on to compile the code into a working .jar file anyway (proving that you don't need IntelliJ).  However, I don't get the ‘unresolved reference’ error, which is the real problem here.  I don't know about Windows, but is your KOTLIN_HOME variable set appropriately? Commented Aug 16 at 18:57
  • @gidds On my windows machine the environment variable name is kotlinc and it is correctly set to C:\Program Files\kotlinc\bin Commented Aug 17 at 16:35

1 Answer 1

2

I moved the kotlinc home folder from C:\Program Files\kotlinc\bin

to C:\kotlinc\bin

Next I deleted the kotlinc user environment variable and appended the new kotlinc home folder location to the Path system environment variable. It now works like a charm.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.