Search code examples
javajavafxjakarta-mailjpackage

JPackage options to include javax.mail


So I have a program that uses javax.mail library, and when I packaged the jar to an installer for windows it gave me an error that I traced back to the to the javax and my guess is there's is some way of including the javax.mail as part of my modules so that it can be be recognized later

Here is a sample of my jpackage command

package -t exe -- name appName --description "some description" --app-version 1.0 --input pathToInput --dest AbsolutePathToDestination --main-jar pathToMainJar --module-path AbsolutePathToJavaFxJmods --add-modules javafx.controls,javafx.base,javafx.graphics,javafx.web,javafx.fxml,java.sql --win-shorcut --win-menu --win-console

Thanks in advance for sharing your knowledge Friends.


Solution

  • So as I guessed, I was missing two modules in my modules list which were:

    • java.compiler
    • java.naming

    After I added the two modules and repackaged them, all was well.

    and so my final jpackage command was as follows:

    package -t exe -- name appName --description "some description" --app-version 1.0 --input pathToInput --dest AbsolutePathToDestination --main-jar pathToMainJar --module-path AbsolutePathToJavaFxJmods --add-modules javafx.controls,javafx.base,javafx.graphics,javafx.web,javafx.fxml,java.sql,***java.compiler,java.naming*** --win-shorcut --win-menu --win-console

    Over my short time of learning JavaFX, I've learned that if the code runs smoothly on the IDE but gives an error on packaging the app, then most of the issues are caused by a missing library or file that has not been included(like a dependency), but of course, that is if it worked in the IDE properly.

    Please feel free to add to this answer

    Hope this helps someone once again, Peace.