andrew blake
andrew blake

Reputation: 21

InvalidModuleDescriptorException: Package hellofx.org.openjfx not found in module

Following the JavaFX IntelliJ modular with Gradle tutorial here, I downloaded the project from github and followed the instructions. When I do gradlew run, I get the error:

> Task :run FAILED
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\ANDREW-SL3\github\hellofx\build\classes\java\main
Caused by: java.lang.module.InvalidModuleDescriptorException: Package hellofx.org.openjfx not found in module

Since I made no modification to the project I assume I've done something else wrong but can't figure out what it is.

Upvotes: 1

Views: 1132

Answers (1)

Juanan
Juanan

Reputation: 1420

I have suffered the same problem. I think that it is related to a change in how latest Gradle versions (>= 6.4) treat modules. In my case this post helped me to solve it.

Basically, add this to your build.gradle file:

java {
    modularity.inferModulePath.set(true)
}

application {
   mainModule = 'hellofx' // name defined in module-info.java
   mainClass = 'org.openjfx.MainApp'
}

run {
   main = "$moduleName/org.openjfx.MainApp"
}

Upvotes: 1

Related Questions