1

I developed a todo list project based on JavaFX on IDEA, which can run well on the IDEA.

And the database that I use is Firebird (2.5.9).

When I package the project into a jar, and use 'exe4j' to package the jar into an exe file, and execute it, the following problems arise:

java.lang.NoClassDefFoundError: java/sql/SQLException
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3434)
    at java.base/java.lang.Class.getDeclaredMethod(Class.java:2705)
    at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:82)
    at com.exe4j.runtime.WinLauncher.main(WinLauncher.java:94)
Caused by: java.lang.ClassNotFoundException: java.sql.SQLException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 5 more

I tries the solution following, but I think it is not completely suitable to my problem. https://stackoverflow.com/questions/73222789/noclassdeffounderror-java-sql-sqlexception-error-postgres-hibernate

And I want that my project can be executable under .exe, that's what I want to do.

4
  • Thanks for your attentions, I found a solution in a chinese website, it works! URL here: zhuanlan.zhihu.com/p/573638445 Commented Aug 27, 2023 at 18:30
  • 3
    If you solved the problem, post and accept an Answer to your own Question, for posterity. Commented Aug 27, 2023 at 19:40
  • 3
    Not just for posterity, but also because it will be helpful to other users in the future. Commented Aug 27, 2023 at 22:03
  • However you converted to .exe did not include the module java.sql. You need to provide a minimal reproducible example. Also, I removed the javafx and firebird2.5 tags, as these are not directly related to those. Commented Aug 28, 2023 at 8:52

1 Answer 1

1

The error is happening due to the Java Module in JDK 17. You have to mention the required packages that you want to use in the project in the module-info.java file like below.

module org.zoftstack.redpos.lite.redposlite {
    requires javafx.controls;
    requires javafx.fxml;

    //requires these packages
    requires java.sql;
    requires mysql.connector.j;
    

    ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.