How to overwrite a class in a jar file

I have a jar file built by someone else. But for one of the java class, I want to use my own version. When running the java program, how to let it reference the class of my own version?
gs_kanataAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CEHJConnect With a Mentor Commented:
One simple way would be to simply unpack it and repack it with your own. You should be OK - unless the archive has been signed
0
 
mccarlConnect With a Mentor IT Business Systems Analyst / Software DeveloperCommented:
Another possibility (althouh not generally advisable) is that if you have full control over the classpath while running your application, you can set the classpath to include the directory/jar file that contains your version of the class BEFORE it includes your 3rd party jar file.

Again, though, I say that this isn't advisible in the general sense. I would only use this as a last resort and only where it isn't critical, ie. I would only do this for an app that I run myself, where I have control over it and I can tell if the "replacement" class didn't get picked up.
0
 
gs_kanataAuthor Commented:
I tried both ways, not that simple.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.