0

Context: I am executing a (third party) jar file from Command Line. The program executes. But when I click a button in the program it results in an error. (Using JDK - 15, JavaFX-15).

Error:

java.lang.ClassNotFoundException: javax.xml.bind.JAXBContext

To execute from command line I am using the below (launches the program):

java -jar --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml programName.jar

Research: Based on these links - Link1 Link2 Link3 & few more in this forum,

I realize that I need to include jaxb jar in the command line. I have downloaded jaxb-api.jar from Maven & kept it in c:\Jar_Files\jaxb-api.jar

I am unable to figure out how I should include the jaxb-api in the command line so that the program does not throw an error when I click the button.

Hope the issue faced is clear, await inputs.

iCoder
  • 1,406
  • 6
  • 16
  • 35
  • 1
    That probably means that the third party jar was not meant to run above JDK11 when JEE/CORBA packages were removed. Does including it in classpath fix the problem? – hamlet Oct 02 '20 at 17:02

2 Answers2

2

Download one of the jakarta bind libs. eg. Maven GAVC: jakarta.xml.bind:jakarta.xml.bind-api:2.3.3

# Downloading libs from maven central
wget https://repo1.maven.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar
wget https://repo1.maven.org/maven2/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar
java -cp jakarta.xml.bind-api-2.3.3.jar;jakarta.activation-api-1.2.2.jar -jar --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml,java.xml,java.xml.bind,jakarta.activation programName.jar
hamlet
  • 127
  • 8
  • tried the above, but still the same error, any other way? – iCoder Oct 02 '20 at 17:25
  • Try adding the module java.xml.bind. Updated my answer – hamlet Oct 02 '20 at 17:41
  • When I enter the above edited suggestion in Command line, it returns an error java.lang.module.FindException: Module jakarta.activation not found – iCoder Oct 02 '20 at 18:01
  • Yes, I expected that and had updated my answer. Can you just not use the modules? Would make life much easier – hamlet Oct 02 '20 at 18:06
  • Which modules I should not use? If I do not specify javafx.controls, javafx.fxml modules then the program will not execute saying JavaFx runtime components are missing. I used your latest revision, even then get the error. Guess am missing something here – iCoder Oct 02 '20 at 18:20
0

The jaxb-api is not enough. You also need the jaxb-runtime.

    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>${jaxb-runtime.version}</version>
    </dependency>               
mipa
  • 10,369
  • 2
  • 16
  • 35
  • I guess you missed my query. It is about how I need to specify the inclusion of jaxb in 'Command Line' as it is a 3rd party JAR file & not a program which I am writing. So adding dependency is not possible. – iCoder Oct 02 '20 at 16:51