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.

1
  • 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? Commented Oct 2, 2020 at 17:02

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

5 Comments

tried the above, but still the same error, any other way?
Try adding the module java.xml.bind. Updated my answer
When I enter the above edited suggestion in Command line, it returns an error java.lang.module.FindException: Module jakarta.activation not found
Yes, I expected that and had updated my answer. Can you just not use the modules? Would make life much easier
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
1

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>               

1 Comment

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.

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.