哪个 .jar 文件有 javax.xml.stream.*?
我在运行 Java 1.5 的 Mac 上再次遇到问题......我在哪里可以获得包含 javax.xml.stream.XMLInputFactory 的 .jar 文件?我想使用 StAX,但不知道如何正确设置。
我似乎无法得到这个设置。我现在已经下载了 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.罐子;将它们全部放入我的 java/lib/ext 目录中,确保它们位于我的 eclipse 构建路径上,删除 Mac com.apple.quarantine 扩展属性,对 .jar 文件执行“chmod a+x”,然后我尝试导入 javax.xml.stream.XMLInputFactory; 时仍然出现以下错误:
访问限制:类型 由于 XMLInputFactory 无法访问 对所需库的限制 /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/jsr173_1.0_api.jar
我需要做什么?
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.
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;
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
What do I need to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
StAX 不是 Java 5 的一部分;您将在 Java 6 然而。
对于 Java 5,您需要下载 StAX 实现并将其放置在类路径中。
Woodstox 就是这样的一个实现。您还可以使用 Sun Java StAX XML 处理器,它已进入 Java SE 6。
除非我'我错了,这两个实现最终都会使用 jsr173_api.jar,您可以在其中找到 javax.xml.stream 包。
更新:
Woodstox 文档会建议您下载 StAX 1.0.1 API jar(使用标准StAX API时需要); Woodstox 中的 StAX2 API jar 将不包含 javax.xml.stream 包(尽管您在运行时需要这两个 JAR)。 Sun 实现依赖于 stax-utils 项目。
更新 2
安装 JSXP
SJSXP 的下载文件区域看起来有点奇怪,因为您有一个类文件,而不是构建 JAR。然而,获取 SJSXP JAR 所需要做的就是执行类文件,该文件会解压发行版。
获取 StAX API JAR
StAX API jar(jsr173_api.jar 等)可以从 StAX 实用程序项目获取。它需要与 sjsxp jar 位于同一目录中。
在 Eclipse 中使用 JAR
无需将 JAR 添加到 JDK 的 lib/ext 中。将这两个 JAR 添加到项目的构建路径中就足够了。
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.
Woodstox is one such implementation. You could also use the Sun Java StAX XML processor, which has made its way into 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.
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-utils project.
Update 2
Installing 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.
Getting the 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.
Using the JARs in Eclipse
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.
我可以向您指出 findjar.com,它允许您输入类名并确定需要哪个 jar。
例如 XMLInputFactory 产量
Can I point you to findjar.com, which allows you to enter a classname and determine which jar is required.
e.g. XMLInputFactory yields