28

I have an IntelliJ project composing several subprojects which are all Java 9 modules. I use Maven as a build system. My project has no "Facets". My run configuration looks like this: Run Configuration

My project settings look like this: Project Settings

I can build everything with Maven just fine. However, when I try to compile with IntelliJ, it somehow thinks that my project is a Kotlin project and can't compile it:

Error message

Error:Kotlin: The Kotlin standard library is not found in the module graph. Please ensure you have the 'requires kotlin.stdlib' clause in your module definition

Has anyone any idea how to fix this? I already tried deleting the run configuration and recreated it. This fixes the problem for some time, but then it reappears randomly.

dax
  • 591
  • 2
  • 6
  • 16

9 Answers9

42

Even in 2019.1.3 that error is there .

A solution that always works for me is :

Build menu => Rebuild Project

Tested with JDK 12.0.1


That should be fixed though by IntelliJ team as soon as possible as more and more Java projects are passing to JDK 11 ++

GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93
17

I had the same problem. I worked in a pure Java project managed with Maven. Till some days ago I applied the solution "rebuild" the project, but sometimes the error came back again.

After more investigation, I found that after disable "Enable migration detection" menu, the problem disappears.

disable menu Enable migration detection

I hope this helps.

xcesco
  • 4,690
  • 4
  • 34
  • 65
3

Try to rebuild the module using Ctrl+Shift+F9 or right click on the module and select "Rebuild " in menu.

  • it doesn't answer the question, I think. Since author mentions that some workaround helps for some time, the goal is to have stable successful build, not just to build once. – Alex Guteniev Feb 26 '19 at 20:15
  • I got above error when I created javafx project using maven archetypes and ran app using intellij run configuration. Rebuild however fixed it – sigirisetti Jun 07 '19 at 05:52
1

Meanwhile, this can be fixed using the kotlin-stdlib.jar available in Kotlin JavaRuntime:

module kotlin.test {
    requires kotlin.stdlib;
}

where kotlin.test should be replaced with your module name.

Just in case the details matter, I am using

IntelliJ IDEA 2018.3 (Community Edition)
Build #IC-183.4284.148, built on November 21, 2018

and the Kotlin JavaRunTime mentioned above has sources from the path Contents/plugins/Kotlin/kotlinc/lib within the IntelliJ .app which includes kotlin-stdlib.jar as one of them.

Naman
  • 27,789
  • 26
  • 218
  • 353
  • 6
    Thanks for the answer, but I do not want to add any requirements to my project to things I do not need... – dax Nov 27 '18 at 14:24
  • 1
    @dax I do understand that, and that's why have used the first word *Meanwhile*. Better solution would the IDE fixing this, which is where you can report a bug as CrazyCoder pointed out. – Naman Nov 27 '18 at 14:29
1

I fixed this error by disabling Kotlin plugin since I am not using it and the problem is solved

0

i had the same problem i deleted the file and start all over again, and its work fine after it

0

Update your module-info.java file

requires javafx.fxml;
requires javafx.controls;
requires javafx.graphics;
requires javafx.web;

opens sample;

opens sample.controller;

It opens the package (eg. sample) which contains your Launcher file and opens package conatinsyoyr controllers and its corresponding fxml files (eg. sample.controller)

p91java
  • 79
  • 1
  • 2
0

This is the Last Option that worked for me.. You need to check few things first

  • try installing the project using

mvn clean install

If the project gets Installed then this is an issue of your IDE being unable to correctly build your project

FIX:: Worked For me Reinstall IDE.. Will save you a day.

-2

I had the same issue. Here is what worked:

  1. On IntellijIDEA go to 'Tools' menu at the top of the application: IntelliJ IDEA IDE.
  2. Then scroll down to 'Kotlin'.
  3. Click 'Configure Kotlin in Project'.
HAVB
  • 1,858
  • 1
  • 22
  • 37