英文:
Error: javax.xml.bind.JAXBContext (Command Line)
问题
Context: 我正在从命令行执行一个(第三方的)jar 文件。程序被执行了。但是当我点击程序中的一个按钮时,出现了一个错误。(使用 JDK - 15,JavaFX-15)。
错误信息:
java.lang.ClassNotFoundException: javax.xml.bind.JAXBContext
为了从命令行执行,我正在使用以下命令(启动程序):
java -jar --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml programName.jar
Research: 基于这些链接 - 链接1 链接2 链接3 以及这个论坛中的其他一些帖子,
我意识到我需要在命令行中包含 jaxb 的 jar 包。我已经从 Maven 下载了 jaxb-api.jar 并将其放在了 c:\Jar_Files\jaxb-api.jar 中。
我无法弄清楚我应该如何在命令行中包含 jaxb-api,以便在我点击按钮时程序不会抛出错误。
希望我所遇到的问题是清楚的,期待您的输入。
英文:
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
得分: 2
下载其中一个Jakarta Bind库。例如,Maven GAVC:jakarta.xml.bind:jakarta.xml.bind-api:2.3.3
# 从Maven中央仓库下载库
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
英文:
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
答案2
得分: 0
jaxb-api是不够的。你还需要jaxb-runtime。
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-runtime.version}</version>
</dependency>
英文:
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论