Error: Could not find or load main class org.jetbrains.kotlin.preloading.Preloader Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.preloading.Preloader

I’m having trouble installing Kotlin on my machine. I’m running Ubuntu 20.04 and I’m following this guide to install it on my machine using SDKMAN. I did the commands but I get this as a result:

Just curious-- Why are you using the command-line compiler? I ask because since I started using Kotlin I haven’t installed or used the compiler directly on my machine.

(When I was originally learning Java I installed and used javac. I haven’t used it after my beginner learning courses except for very rare occasions)

1 Like

Try to delete home/roshad/Kotlin/compiler and use SDKMAN kotlinc. Also it may help to use a lower version of JDK.

Someone found a way to use Kotlin in VSCode and I’m trying to follow the steps needed to set up my environment to run a single kotlin file in the editor without a build system and/or project structure. The instructions require me to put kotlinc in my PATH, so I manually installed the Kotlin zip from Github and only extracted the compiler folder. The guide also says to add the bin directory to the system path. The only bin directory I could find was in the cli folder. So with all that done, I was hoping to simply create a kotlin file, start coding, compiling, and running it. This is so that I can practice with language and use it for coding challenges on HackerRank and Leetcode.

You’re right, it works if I remove the path but I don’t know if that’ll allow me to do what I need it to do. I’m following some instructions to get a kotlin file running in my editor without the use of a build system. I’m looking for IDE support for the language in my editor.

Can’t you just use the kotlin compiler from .sdkman installation? It should be basically the same thing.

That’s what I thought and I can technically write and run a kotlin file but my ultimate goal is to get the VSCode extension to work so I can get IDE support. Right now with sdkman the extension isn’t working properly and I’ve been on the extension’s Discord server and Github page asking and researching the issue. I just don’t want to install an entire IDE to write some kotlin code that’s only 3 lines and prints hello world. The extension allows me to write the code and get features like completion, diagnostics, hover, formatting, goto definitions, and so on without having to create a project structure and build system for each simple program I write.