iCoder
iCoder

Reputation: 1524

Error: javax.xml.bind.JAXBContext (Command Line)

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.

Upvotes: 0

Views: 1283

Answers (2)

hamlet
hamlet

Reputation: 127

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

Upvotes: 2

mipa
mipa

Reputation: 10640

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>               

Upvotes: 1

Related Questions