How to fix "Unable to derive module descriptor for .jar file" error in fxml
Asked Answered
L

3

5

I would like to get an image from JAR library to my project.

    <graphic>
        <ImageView>
            <Image url="@/toolbarButtonGraphics/general/TipOfTheDay24.gif"/>
        </ImageView>
    </graphic>

I've added the library to my module and it seemed to be correct but the compiler throws an error: Error occurred during initialization of boot layer java.lang.module.FindException: Unable to derive module descriptor for filepath.jar Caused by: java.lang.IllegalArgumentException: jlfgr.1.0: Invalid module name: '1' is not a Java identifier. Here's my module-info file:

requires javafx.fxml;
requires javafx.controls;

opens sample;
Lodi answered 24/4, 2019 at 12:19 Comment(3)
So you have your modular app, and you add a dependency (the jar with the image)? This jar is jlfgr.1.0.jar? Why don't you add the jar to the module info? Have you tried renaming it to jlfgr-1.0.jar?Glans
Adding to the module-info after renaming a file helped :) Thank you so much.Lodi
Does this answer your question? Unable to derive module descriptor for auto generated module names in Java 9?Temporal
O
5

it seems like you did not follow the steps properly. When you add a new library, first, you add it to your module and then you have to add it to you module-info file.

Just add a line in module-info ---> requires <package-name>;

e.g my package name is graphics-looks.jar ---> requires graphics-looks;

P.S. before adding that jar anywhere, try to rename it and give a simple name by removing numbers and other characters from its name.

Outdated answered 13/6, 2020 at 14:17 Comment(2)
I faced the same issue mentioned above and this solution worked for me. Having numbers and special characters in my jar file was not allowing to add in the module-info file as it is. had to rename the jar file and use.Praise
Package name having numbers and special character made it difficult to add it to the module-info. To make it clear, what worked for me is getting rid of the numbers and the special characters. Example: renaming jlfgr-1_0 to jlfgrBlakney
A
1

According to Tarun Dadlani Answer.

Firstly, you need to add the .jar file to Modules as the pictures shown. Add .jar file to modules

Secondly, you need to add a new lib to module-info file as the pictures shown. Add a new lib to module-info file

Finally, Rename the .jar file to give a simple name.

Acidophil answered 22/4, 2021 at 22:44 Comment(0)
G
0

Switch the project programming language, set it to version 11 on both sdk and language level. it worked for me.

Ginnygino answered 23/9, 2020 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.