哪个 .jar 文件有 javax.xml.stream.*?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1319264/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 08:11:39  来源:igfitidea点击:

which .jar file has javax.xml.stream.*?

javaxmlstax

提问by Jason S

I have problems again with my Mac running Java 1.5.... where do I get a .jar file that has javax.xml.stream.XMLInputFactory ? I want to use StAX but don't know how to get it set up right.

我的 Mac 运行 Java 1.5 时再次出现问题.... 我从哪里获得具有 javax.xml.stream.XMLInputFactory 的 .jar 文件?我想使用 StAX 但不知道如何正确设置它。



I can't seem to get this setup. I've now downloaded jaxp-api.jar, jsr173_1.0_api.jar, sjsxp.jar, stax-api-1.0.1.jar, stax2-api-3.0.1.jar, and woodstox-core-asl-4.0.5.jar; put them all into my java/lib/ext directory, made sure they're on my eclipse build path, removed the Mac com.apple.quarantine extended attribute, did a "chmod a+x" on the .jar files, and I still get the following error trying to import javax.xml.stream.XMLInputFactory;

我似乎无法获得此设置。我现在已经下载了 jaxp-api.jar、jsr173_1.0_api.jar、sjsxp.jar、stax-api-1.0.1.jar、stax2-api-3.0.1.jar 和 woodstox-core-asl-4.0。 5.jar; 将它们全部放入我的 java/lib/ext 目录中,确保它们在我的 eclipse 构建路径上,删除了 Mac com.apple.quarantine 扩展属性,在 .jar 文件上做了一个“chmod a+x”,然后我仍然会收到以下错误尝试import javax.xml.stream.XMLInputFactory;

Access restriction: The type XMLInputFactory is not accessible due to restriction on required library /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/jsr173_1.0_api.jar

访问限制:由于对所需库/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/jsr173_1.0_api.jar的限制,无法访问类型XMLInputFactory

What do I need to do?

我需要做什么?

采纳答案by Vineet Reynolds

StAX is not a part of Java 5; you'll find it in Java 6, however. For Java 5, you'll need to download a StAX implementation and place it in the classpath.

StAX 不是 Java 5 的一部分;但是,您会在Java 6 中找到它。对于 Java 5,您需要下载 StAX 实现并将其放置在类路径中。

Woodstoxis one such implementation. You could also use the Sun Java StAX XML processor, which has made its way into Java SE 6.

Woodstox就是这样一种实现。您还可以使用Sun Java StAX XML 处理器,它已进入 Java SE 6。

Unless I'm mistaken, both of these implementations will eventually use the jsr173_api.jar, where you'll find the javax.xml.stream package.

除非我弄错了,否则这两种实现最终都将使用jsr173_api.jar,您将在其中找到 javax.xml.stream 包。

Update:

更新:

The Woodstox documentation would refer you to download the StAX 1.0.1 API jar(required when you use the standard StAX API); the StAX2 API jar in Woodstox will not contain the javax.xml.stream package (although you'll need both JARs at runtime). The Sun implementation depends on the stax-utilsproject.

Woodstox 文档会建议您下载StAX 1.0.1 API jar(使用标准 StAX API 时需要);Woodstox 中的 StAX2 API jar 将不包含 javax.xml.stream 包(尽管您在运行时需要两个 JAR)。Sun 的实现依赖于stax-utils项目。

Update 2

更新 2

Installing JSXP

安装 JSXP

The download files area of SJSXP looks a bit weird, in that you have a class file, instead of build JARs. However, all that is needed to obtain the SJSXP JAR, is to execute the class file, which unpacks the distribution.

SJSXP 的下载文件区域看起来有点奇怪,因为您有一个类文件,而不是构建 JAR。但是,获取 SJSXP JAR 所需的全部工作是执行类文件,该文件解压缩分发包。

Getting the StAX API JAR

获取 StAX API JAR

The StAX API jar (jsr173_api.jar or the like) can be obtained from the StAX utilities project. It needs to be in the same directory as the sjsxp jar.

StAX API jar(jsr173_api.jar 等)可以从 StAX 实用程序项目中获得。它需要与 sjsxp jar 位于同一目录中。

Using the JARs in Eclipse

在 Eclipse 中使用 JAR

It is not necessary to add the JARs to lib/ext of the JDK. It is enough to add the two JARs to the Build Path of the project.

没有必要将 JAR 添加到 JDK 的 lib/ext 中。将两个JAR添加到项目的Build Path就足够了。

回答by Brian Agnew

Can I point you to findjar.com, which allows you to enter a classname and determine which jar is required.

我可以指向findjar.com,它允许您输入类名并确定需要哪个 jar。

e.g. XMLInputFactoryyields

例如XMLInputFactory产量

jsr173_1.0_api.jar
jsr173_api.jar
stax-api-1.0.1.jar
stax-api-1.0.1.jar
stax-api-1.0.jar
groovysoap-all-jsr06-0.1.jar