How to fix “Unable to derive module descriptor for .jar file” error in fxml

落花浮王杯 提交于 2021-02-08 05:27:14

问题


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;

Thanks for any help!


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/55829893/how-to-fix-unable-to-derive-module-descriptor-for-jar-file-error-in-fxml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!