Solved

How to overwrite a class in a jar file

Posted on 2013-12-12
3
998 Views
Last Modified: 2013-12-17
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?
0
Comment
Question by:gs_kanata
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 39714553
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
 
LVL 35

Assisted Solution

by:mccarl
mccarl earned 250 total points
ID: 39715446
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
 

Author Closing Comment

by:gs_kanata
ID: 39724976
I tried both ways, not that simple.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question