Greetings
I have a JavaFX project that has a dependency on JAXB APIs that I developed using Netbeans 12.0, JDK 14.0 on Windows 10. Since JAXB APIs migrated from Java SE to JEE, they reside in an external javaee-api-6.0 jar file within the Netbeans installation directory. I have managed to compile and run the project within the IDE, however, I have created a jar for this project and I am trying to run it from the Windows command prompt (outside of the IDE). I leveraged this invaluable resource to get started (https://stackoverflow.com/questions/55652036/how-to-start-javafx-11-application-outside-ide/55653652#55653652), however, my scenario slightly varies.
Here is my module-info:
module org.openjfx.mavenfxedittableview {
requires javafx.controls;
requires javafx.fxml;
requires java.base;
requires java.prefs;
requires transitive java.xml.bind;
opens org.openjfx.mavenfxedittableview to java.xml.bind, javafx.fxml;
exports org.openjfx.mavenfxedittableview;
}
Here is the JAXB related dependencies in the pom.xml:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
I have copied the javaee-api-6.0.jar from the Netbeans into C:\MyLibs directory and created a system environment variable that is included in the system classpath:
JAVA_EXT=C:\MyLibs
I have jarred the project with the META-INF/MANIFEST.MF pointing to the main class:
Main-Class: org.openjfx.mavenfxedittableview.TableEditApp
Here is the import statement in my main class that pulls in the JAXB (java.ml.bind):
import javax.xml.bind.JAXBContext;
Here is the content of my jar file:
0 Tue Sep 08 07:34:02 IRDT 2020 META-INF/
125 Tue Sep 08 07:34:02 IRDT 2020 META-INF/MANIFEST.MF
2502 Sat Sep 05 15:19:46 IRDT 2020 org/openjfx/mavenfxedittableview/addressBookData.xml
9562 Sat Sep 05 15:19:46 IRDT 2020 org/openjfx/mavenfxedittableview/Address_Book.png
859 Sat Sep 05 15:19:46 IRDT 2020 org/openjfx/mavenfxedittableview/birthdaystatistic.fxml
2602 Sun Sep 06 18:34:38 IRDT 2020 org/openjfx/mavenfxedittableview/BirthdaystatisticController.class
3224 Sat Sep 05 15:19:46 IRDT 2020 org/openjfx/mavenfxedittableview/DarkTheme.css
1824 Sun Sep 06 18:34:38 IRDT 2020 org/openjfx/mavenfxedittableview/DateUtil.class
967 Sun Sep 06 18:34:38 IRDT 2020 org/openjfx/mavenfxedittableview/LocalDateAdapter.class
2962 Sun Sep 06 18:34:38 IRDT 2020 org/openjfx/mavenfxedittableview/Person.class
4535 Sat Sep 05 15:19:46 IRDT 2020 org/openjfx/mavenfxedittableview/personeditdialog.fxml
4566 Sun Sep 06 18:34:38 IRDT 2020 org/openjfx/mavenfxedittableview/PersoneditdialogController.class
839 Sun Sep 06 18:34:38 IRDT 2020 org/openjfx/mavenfxedittableview/PersonListWrapper.class
6412 Sat Sep 05 15:19:46 IRDT 2020 org/openjfx/mavenfxedittableview/personoverview.fxml
1904 Sat Sep 05 15:19:46 IRDT 2020 org/openjfx/mavenfxedittableview/rootlayout.fxml
3741 Sun Sep 06 18:34:38 IRDT 2020 org/openjfx/mavenfxedittableview/RootlayoutController.class
7433 Sun Sep 06 18:34:38 IRDT 2020 org/openjfx/mavenfxedittableview/TableEditApp.class
5966 Sun Sep 06 18:34:38 IRDT 2020 org/openjfx/mavenfxedittableview/TableVieweditController.class
349 Tue Sep 08 07:34:04 IRDT 2020 module-info.class
Here is the java command I use to run the jar file for the module:
java -p "%JAVAFX_HOME%\lib;%JAVA_EXT%;org\openjfx\mavenfxedittableview" -m org.openjfx.mavenfxedittableview
Here is the system error response:
C:\Users\hrh74\Downloads\Lib\table>java -p "C:\Program Files\java\jFX\javafx-sdk-14.0.2.1\lib;c:\MyLib\;org\openjfx\mavenfxedittableview" -m org.openjfx.mavenfxedittableview
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.xml.bind not found, required by org.openjfx.mavenfxedittableview
Any idea, how to include an external jar file, when running a module from the command line, so it can be found?
Update 1:
I have run the following command to find out the module name for the javaee-api-6.0.jar file.jar --file=javaee-api-6.0.jar --describe-module | more
The module name for the jar file is javee.api as accurately predicated by slaw in the comments.
No module descriptor found. Derived automatic module.
javaee.api@6.0 automatic
I updated my module-info file with this module name, however, I the Netbeans IDE warns that it cannot find this module, thought the actual javaee-jar-6.0.jar is in the Netbeans internal library and part of the project classpath.
Despite, the warning, the project compiles but at runtime (within the IDE and not the command prompt, which is my goal) it displays an error when it tries to use the JAXB APIS. If I supplant javaee.api with java.xml.bind in the "opens" statement of module-info then everything works within IDE (not the command prompt).
If, I don't make any modification in the module-info file and just try to run the application jar file from the command line using module name javaee.api for the javaee-api-6.0.jar file:
java -p "C:\Program Files\java\jFX\javafx-sdk-14.0.2.1\lib;c:\MyLib" --add-modules javafx.controls,javaee.api -jar org\openjfx\mavenfxedittableview\mavenfxedittableview.jar
Then I receive the following response:
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules javaee.api and java.xml export package javax.xml.stream.util to module javafx.swt
Thanks in advance.