2

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

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.

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)

Please note I dont use any IDE. All I use is Editplus and command prompt

user961954
  • 3,214
  • 2
  • 17
  • 24

1 Answers1

1

The correct way to do it is

jar cfm0 my.jar MANIFEST META-INF/services/javax.xml.parsers.SAXParserFactory *.class
user961954
  • 3,214
  • 2
  • 17
  • 24