Search code examples
javaeclipsejavafxluaj

JavaFX and luaj in eclipse - java.lang.module.InvalidModuleDescriptorException: luajc.class found in top level directory


I have to convert my project from SWT to JavaFX. This project made a great use of luaj for coercion and executions of lua scripts and worked well in swt.

But there a difference with javafx. Javafx works as a module.

Since then, I have troubles with luaj.

Tried two different ways:

** With luaj in the class path**

Eclipse doesn't see it anymore (The type org.luaj.vm2.[...] is not accessible). Tried to play with the order but still not working.

With luaj as a auto-named module

I tried as a user lib or directly as an external jar.

In this case, eclipse sees luaj packages. But when I run, I have the message

Error occurred during initialization of boot layer

java.lang.module.FindException: Unable to derive module descriptor for E:\eclipse-workspace\Lib\luaj-3.0.1\lib\luaj-jse-3.0.1.jar Caused by: java.lang.module.InvalidModuleDescriptorException: luajc.class found in top-level directory (unnamed package not allowed in module)

I think that the lib file is badly named. I have a warning saying "Name of automatic module luaj.jse is unstable", but when I try to rename it, I have an error as eclipse search the old file name.

It can be de cause?

I use jdk-16

here my module-info...

module dusandbox {
    requires javafx.graphics;
    requires javafx.controls;
    requires javafx.base;
    requires javafx.fxml;
    requires javafx.media;
    requires javafx.swing;
    requires javafx.swt;
    requires javafx.web;
    requires java.xml;
    requires luaj.jse;
    
    exports dusandbox;
    exports dusandbox.setup;
    exports dusandbox.obj;
    opens dusandbox.setup to javafx.fxml;
    opens dusandbox.obj to javafx.fxml;
}

VM Arguments

--module-path "E:\eclipse-workspace\Lib\javafx-sdk-11.0.2\lib"
--add-opens javafx.graphics/com.sun.javafx.text=ALL-UNNAMED

.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="lib" path="E:/eclipse-workspace/Lib/luaj-3.0.1/lib/luaj-jse-3.0.1.jar">
        <attributes>
            <attribute name="module" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry excluding="fxml/|picture/|pictures/" kind="src" path="src">
        <attributes>
            <attribute name="module" value="true"/>
            <attribute name="add-exports" value="dusandbox/dusandbox.setup=dusandbox"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JavaFx">
        <attributes>
            <attribute name="module" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
        <attributes>
            <attribute name="module" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="lib" path="E:/eclipse-workspace/Lib/javax.xml.bind.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

Thank you for your help! I am searching since 2 days and I am very confused!

Edit Seem that luaj can't work as module. I am still stuck at making it work in the classpath...


Solution

  • SOLVED

    I removed the module-info and added all javafx libs in the module-path.

    I replaced the VM arguments by

    --module-path "E:\eclipse-workspace\Lib\javafx-sdk-11.0.2\lib"
    --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.web
    

    Notice that you have to select which javafx modules you want to use in the add-modules argument.