将META-INF\services\javax.xml.parsers.SAXParserFactory添加到jar [英] Adding META-INF\services\javax.xml.parsers.SAXParserFactory to jar
问题描述
我有一个包含少量类文件的文件夹,我用来创建jar的命令是
I have a folder which has few class files, the command i was using to create a jar was
jar cfm0 my.jar MANIFEST *.class
现在我还要将以下内容添加到jar META-INF \ services\javax.xml.parsers.SAXParserFactory。请建议将使用类创建jar的命令和META-INF \services \ _javax.xml.parsers.SAXParserFactory。
Now I also want to add following to the jar META-INF\services\javax.xml.parsers.SAXParserFactory. Please suggest what will be the command which will create a jar with classes and META-INF\services\javax.xml.parsers.SAXParserFactory.
我想到了篡改使用jar即使用7z添加META-INF \services \ _javax.xml.parsers.SAXParserFactory但是不相信。
I thought of tampering with jar i.e. add META-INF\services\javax.xml.parsers.SAXParserFactory using 7z but wasnt convinced.
使用此命令会返回以下错误
Using this command returns following error
jar cfm0 CAM_AAA_JDBCPowerReports.jar META-INF/services/javax.xml.parsers.SAXParserFactory *.class
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:389)
at java.util.jar.Manifest.read(Manifest.java:180)
at java.util.jar.Manifest.<init>(Manifest.java:50)
at sun.tools.jar.Main.run(Main.java:149)
at sun.tools.jar.Main.main(Main.java:1147)
请注意我不使用任何IDE。我使用的只是Editplus和命令提示符
Please note I dont use any IDE. All I use is Editplus and command prompt
推荐答案
正确的方法是
jar cfm0 my.jar MANIFEST META-INF/services/javax.xml.parsers.SAXParserFactory *.class
这篇关于将META-INF\services\javax.xml.parsers.SAXParserFactory添加到jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!