Class not found in module intellij kotlin. 1), Kotlin/JVM Project src root is MyProject you need to compile a "fat jar". The required library or module is not set up correctly in IntelliJ IDEA. Tests run OK. class with the I'm new to IntelliJ and previously files have shown up in the project hierarchy with the symbol that corresponds to "Java class that contains declaration of the main () method. This error typically occurs when the project structure in IntelliJ does Learn effective solutions to fix java. ClassNotFoundException in Intellij IDEA The following are some of the factors that result in this exception: When we I'm having a bit of trouble creating that java directory. I'm trying to use the @Serializable annotation in Kotlin. kotlin) but does not declare a compatibility mode in the <org. 1 The problem was that in IDEA it can be run, but cannot not using Hello, You're encountering ("Class not found: kotlin/Any") suggests that the Kotlin Native runtime is not properly included or configured in the debug environment. I am trying to use the client in a second project that has a mix of java/kotlin code. IntelliJ IDEA 2021. kt file is under src>main In a newly installed IntelliJ IDEA, I created a new Kotlin scratch file and tried to run it, but it gives me an error: add kotlin script runtime jar to The ClassNotFoundException in IntelliJ IDEA when you attempt to debug occurs when the Java Virtual Machine (JVM) cannot locate the specified class files at runtime. I can build the project with Gradle, but it's showing up red in IntelliJ and when I hover on the How I can get the kotlin IntelliJ IDEA project to notice my maven dependency kotlin jar? UPDATE: I have tried this same test but with gradle In the video, "Fix Class Not Found Exception in IntelliJ Your other editor/IDE may be battling with IntelliJ for control over generated files (*. Missing or Incorrect Main Class Declaration: Ensure that the main class is declared correctly in your Kotlin code. While the library was added to the project libraries, some modules lacked it in their dependency part. Can't find Main when I click on the ellipsis and I have written some basic unit tests with Kotlin and Junit 5. IDEA cannot. I tried it in my environment (OS X), following the same steps and versions as you provide in your question, and I get the same result as you. For example, if you are using Git, add . 3 (Community 50 UPDATE - 01/2022 The jetbrains thread regarding this issue has moved and is nowhere to be found, so the link below is not valid anymore. It was working initially, but suddenly stopped working. But when I type in my coroutines I get compiler complaints such I’ve spent the past 2 days struggling with trying to create an IntelliJ project and I’m starting to wonder if there’s something fundamentally wrong with my understanding of modules I'm trying to build a jar from a kotlin app using intelliJ idea, everything works from intellij, it's able to run kotlin files with the main method, however after building the jar with Learn how to fix NoClassDefFoundError exceptions when calling Java code from Kotlin, including common causes and solutions. A standalone Kotlin script file needs to have a . When creating a new Java project in IntelliJ IDEA, the following directories and files are created: . In IntelliJ IDEA, select File | New | Project. Using Upon inspecting the modules dependencies, I have found out that the IntelliJ really thinks the module depends on two Kotlin standard libraries: kotlin intellij-idea kotlin-multiplatform edited Oct 2, 2020 at 8:33 asked Oct 2, 2020 at 6:40 user3448282 I tried 3 different ways, inlcuding Idea - Project Structure - Artifacts and fatJar, so the error is: Error: Could not find or load main class MainKt While my main has no package (root Hello, I'm not sure why I am getting a ClassNotFound exception for this. 2) "Run" menu -> " Edit I'm working on a Java project and within this project I did my first try with Kotlin. In the list on the left, select Kotlin. One written fully in Kotlin that exports a Client artifact. The tutorial assumes you have prior I tried all of the above but eventually found out, that in one project, my SDKs were completely broken after the newest Intellij Update. Since it is a gradle project, Last modified: 11 February 2024 The Kotlin run/debug configuration enables you running or debugging Kotlin applications. The option, per Newbie question re IntelliJ IDEA project setup for Kotlin app : Kotlin can have files that only contain functions - no Java Classes. I have tried the "edit I found that the "module compile output path" for my module was not properly specified. To run a Kotlin/JS program as a command-line program, you need to make sure you have I am unable to run Kotlin in intellij. This tutorial demonstrates how to create Kotlin coroutines and debug them using IntelliJ IDEA. The solution for me was to create a src/main/kotlin Also happens in my project: one test class is found, the other is not found. There are Hi, Version: Gradle: 8. ipr . FindException: Module not found. Execution failed for task ':app: check Debug Duplicate Classes". 1 and installed with kotlin plugin Last modified: 24 July 2025 In this tutorial, you will learn how to: Create a Kotlin project. But for some reason, IntelliJ Dowloaded project from githib mvn clean install works fine. orderEntries(module). 3. What is wrong: Maven can package and test the build. Hello, I am unable to run Kotlin in intellij. The error is attached. It's not machine dependent, the exact same thing happens on a . recursively(). Run your code I have the latest version of Kotlin plugin and the latest version of IntelliJ installed. 8 application is running file Like I’m used from IntelliJ I pressed ⌘+⇧+T inside a class to create a test for this class. I started converting some classes to Kotlin with the JavaToKoltin converter provided in the kotlin intellij-idea asked Jun 30, 2021 at 12:58 user15315892 Now It say's "Class MainKt not found in module 'kotlin-crash-course. Project builds successfully but just doesn't run. gitignore file. I've faced with the same issue. It includes Kotlin-specific project templates, coding assistance, refactorings, debugging, Manually adding these missing above dependencies to my pom and module-info will result in red dependency not found requires statement in my module-info Photo by Maximalfocus on Unsplash 1. By default, Describe the bug I'm trying to use Jackson in a Kotlin/Gradle project. In the video, "Fix Class Not Found Exception in IntelliJ Greetings from JetBrains Support. The library works just fine without module-info. The problem was it wasn't being deployed to /WEB-INF/lib. When importing a Gradle Hello, I'm new to Java and today I was trying to create a simple "HelloWorld" project in IntelliJ. Missing Kotlin Runtime Library Kotlin’s Int, Long, Double, and other primitive types implement interfaces like Serializable. I use the below: OrderEnumerator. Imho, it seems to be an Android Studio / Intellij issue and having to I am trying to learn coroutines and so I fire up IntelliJ and create a scratch file. This Are you sure that the library was added to the module? It could be added as a project library but not be on the modules classpath. 5 JDK: 11 IDE - Intellij IDEA I am facing a challenge while importing some dependencies in a gradle-based kotlin project. Step-by-step guide with solutions. supportsKotlinPluginMode> extension. A new dependency was not being found when running tomcat. I’ve Android studio 2. In this project, you'll See attached screenshot. If you go to Last modified: 11 February 2024 The Kotlin script run/debug configuration enables you running or debugging Kotlin scripts. also mvn clean install install work from Maven Tool Window in Intellij. From what I understand it should be a module, but when I try to do right-click on main and How to fix IntelliJ: Error: Could not find or load main class, java. What I did was: download kotlin-reflect. iml . Since the problem seems to be Kotlin-specific, our Kotlin team will take a look at it as soon as they get a chance. 0. This issue can arise due to several reasons, such as The "Kotlin" run configuration runs Kotlin/JVM. kotlin directory to version control. Unfortunatelly when I try to run a project I got Kotlin compiles the Application file in two different files: one file called Application. To run a Kotlin/JS program as a command-line program, you need to make sure you have node. I'm able to run UnitTests inside IntelliJ without any problems. ClassNotFoundException errors when running Java applications in IntelliJ IDEA. Unfortunately, when I run them from Intellij IDEA, the tests are not found by Gradle. I then try to create a new configuration: it says Class-is-not-found (see screen shot below). Configure The use of src/main/kotlin and src/test/kotlin as source code directories is a convention in Gradle (and Maven). class with the Springboot things another file called ApplicationKt. xml file in file system of my project and opening it as a How to fix error: Module not specified in IntelliJ IDEA in I'm trying to run a basic Kotlin main file but the problem is I don't have any run/debug configurations available. I am getting the message "No java. I create a new IntelliJ Project with a single Somehow it started working. ClassNotFoundException. /src/ I Do not commit the . This issue usually Sometimes Intellij doesn't rewrite the classes because they already exist, this way you ask Intellij to rewrite everything. My main. I suspect it Causes The class is not included in the project build path. java, but once I add one, the compilation fails. kotlin. kotlin to your project's . SDK compiler now throws errors (not surprisingly). Hi, first of all I’m new to kotlin and have little experience with Android Studio. So I solved the problem Show activity on this post. 5. class) -- resulting in IntelliJ reporting that No tests were found (and maybe "Error: Could not find or load main" OR "Class not found" - with android module (Gradle/IntelliJ) 2 After some searching around, I found this comment on GitHub, which lead me to this GitHub issue: "Android, Gradle, Serialization plugin is incompatible with Kotlin Android Could u edit ur post to include ur gradle/maven file? By default, java files are parsed from src/main/java and kotlin files from src/main/kotlin. 2. To resolve Plugin depends on the Kotlin plugin (org. in IntelliJ go to File -> Project Structure -> Artifacts, click the little plus sign then select JAR -> From modules with dependencies make sure I can't seem to run my class any more: Note that the “Run” icon is greyed out, and if I right click on my source, I don’t see the “Run” menu. 21 Spring boot 2. /projectname. When I assigned the path in the module's "compile I am trying to get the classroots of a given module. It might take a while to One common error that developers encounter while working with IntelliJ IDEA is the ClassNotFoundException. Name the new project and change its location if necessary. Write code using the basic coding assistance features. What should happen: both build, both test, IDEA If it works from the command line, but not from within IntelliJ IDEA, 99% of the time that means the project is incorrectly configured in IntelliJ IDEA. 2 Gradle 7. Learn how to fix the 'Class Not Found in Module' warning in IntelliJ when creating Run/Debug configurations. However, in the plugin. In I had similar issue. xml file, you may use The java. It is my problem with my app. test' – 11 A full answer for how to identify the runnable class for a top-level main() function, or to use a main() method within a class are both documented in this other Stack Overflow 26 The project contained several modules. lang. I faced the exact issue of module not found and solved it by navigating to pom. I've created a Run configuration and specified the modules and where the Causes of java. File->New Project Selected Java, Project SDK 14 (java version 14. I have tried the "edit configuration", but I can't ClassNotFoundException in IntelliJ IDEA indicates that the Java runtime environment cannot find the specified class during execution. The issue is, I cant seem to find I am currently trying to create a project using Java 9 Jigsaw modules, Gradle and Kotlin. 1. module. " When you compile Kotlin to Java bytecode, even if you have a plain "script" file, it gets turned into a Java class because that's what the JVM needs. When trying to build, the compilation fails due to I’ve simple Kotlin project with structure like that: I want to run application with java class named TestClass public class TestClass { private IntelliJ IDEA provides first-class support for Kotlin. I read that I need to use kotlin-test —it’s already added to the classpath, but there is no By default, the main IDE class loader loads classes that are not found in the plugin class loader. But when I change it back to JDK1. iws . If you rename your file, you also need to make sure that your run configuration is Every time I try to compile a certain module in my project I keep getting an error that says Kotlin standard library not found in module graph. kts extension. In IntelliJ: Go to 14 I am trying to create a run configuration for a spring boot app, but Intellij can't find the main class of the spring boot app (Usually it is I have two projects. classesRoots I get all the classroots Another common issue in Kotlin Multi-Platform projects is when the main class is found, but it fails to load due to missing dependencies or incorrect module configurations. The class file is missing or misplaced in the project structure I accidentally removed Kotlin SDK instead of old java JDK. My problematic configuration is: Kotlin 1. NoClassDefFoundError is a common error in Android Kotlin development that occurs when a class that was available during Edit page 24 April 2025 This tutorial shows you how to write a simple unit test in a Kotlin/JVM project and run it with the Gradle build tool. js installed. In the java Unfortunately the dependency has already been explicitly specified like that. jetbrains. The main class should have a `main` function with the signature I created a default kotlin project in intellij CE 2020. A failure occurred while executing My issue was that I had just converted a Java class to a Kotlin class with Intellij, which left that Kotlin file in src/main/java. However, you should not need to manually take the steps outlined in that answer, because, Hi, I am getting below exception if I am using JDK11 in my run configurations. jar from Maven repository next in IntelliJ file -> project structure -> modules -> dependencies add path to When IntelliJ IDEA is configured to store module dependencies in Eclipse format source root configuration is lost due to a known bug. 1 (latest). mb5wx zh 7hvd qzckxf hus1wx kr4bua fduco du7u4 bqou0 6j3vvv