deleyd
asked on
Updating a .jar file
I have a Java .jar file (Saxon-HE-9.8.0-7.jar). I want to modify this .jar file.
My first attempt was to add a new class to it. All seemed to go well, until I tested it, and the calling program insisted it could not find the new class.
This was my new class:
I compiled it at a Windows Command Line using javac.exe
This created file TransformerFactoryImpl2.cl ass
Then I added this new class to the .jar file:
Did I miss a step? Is there a manifest somewhere I need to add this new class to?
Since this approach did not work, my next idea was to modify the original class. I disassembled the original class, modified it, recompiled it using the same technique as above, then updated the jar file using the same technique as above. I then unzipped the resulting jar file, and found I had two copies of file TransformerFactoryImpl.cla ss in two different places: the original class where it belonged in the net\sf\saxon directory, and my new class in the top level directory.
What step am I missing?
My first attempt was to add a new class to it. All seemed to go well, until I tested it, and the calling program insisted it could not find the new class.
This was my new class:
package net.sf.saxon;
public class TransformerFactoryImpl2 extends TransformerFactoryImpl
{
public TransformerFactoryImpl2()
{
this.setAttribute("http://saxon.sf.net/feature/ignoreSAXSourceParser", true);
}
}
I compiled it at a Windows Command Line using javac.exe
java.exe -cp Saxon-HE-9.8.0-7.jar TransformerFactoryImpl2.java
This created file TransformerFactoryImpl2.cl
Then I added this new class to the .jar file:
jar uf Saxon-HE-9.8.0-7.jar TransformerFactoryImpl2.class
Did I miss a step? Is there a manifest somewhere I need to add this new class to?
Since this approach did not work, my next idea was to modify the original class. I disassembled the original class, modified it, recompiled it using the same technique as above, then updated the jar file using the same technique as above. I then unzipped the resulting jar file, and found I had two copies of file TransformerFactoryImpl.cla
What step am I missing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)
ASKER
I have only one problem, which is now:
"java.lang.SecurityExcepti
So looks like modifying Saxon-HE-9.8.0-7.jar itself isn't going to be viable.
I'll start another question asking for creative solutions around this.
Thank you!