adding further functionality to a java program

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2007
Posts: 60
Reputation: Grub is an unknown quantity at this point 
Solved Threads: 0
Grub Grub is offline Offline
Junior Poster in Training

adding further functionality to a java program

 
0
  #1
Oct 27th, 2008
I have a .jar file; in this .jar file I have many .class files but no .java files for these class files. Is it possible to add functionality to the program? If so how?
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: adding further functionality to a java program

 
0
  #2
Oct 27th, 2008
Originally Posted by Grub View Post
I have a .jar file; in this .jar file I have many .class files but no .java files for these class files. Is it possible to add functionality to the program? If so how?
since you don't have the java files, I take it you didn't write the original code.

if you did write the code, you could try to decompile it, and 'add' code, but if it isn't yours, I would just write some extra classes that use the methods you want to 'improve' and that fix your problem. or, you can write some new classes that extend the older ones, and overwrite the methods you want to see executed otherwise
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 138
dickersonka dickersonka is offline Offline
Veteran Poster

Re: adding further functionality to a java program

 
0
  #3
Oct 27th, 2008
Agree with stultuske. You need to create something like a "wrapper" class. Lets say for example the jar file will load an employee, but you want to add a check if the employee is still active.

Create a method in your wrapper class to call the jar and load the employee, then add in your check for active into your wrapper class as well.
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 60
Reputation: Grub is an unknown quantity at this point 
Solved Threads: 0
Grub Grub is offline Offline
Junior Poster in Training

Re: adding further functionality to a java program

 
0
  #4
Oct 27th, 2008
The problem is, I am not the author of the original and as such have not clue as to what methods the classes have and in which class.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,652
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: adding further functionality to a java program

 
1
  #5
Oct 27th, 2008
>The problem is, I am not the author of the original and as such have not clue as to what
> methods the classes have and in which class.

Then how do you propose on adding additional functionality as mentioned in your first post?
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 60
Reputation: Grub is an unknown quantity at this point 
Solved Threads: 0
Grub Grub is offline Offline
Junior Poster in Training

Re: adding further functionality to a java program

 
0
  #6
Oct 27th, 2008
The question was is it possible? I never once implied I intended to do so. Is it possible to add functionality, if so under waht circumstance and how.

From what I can deduce from the replies, there is the suggestion that yes, if I know the classes and the methods and no if you do not know anything about them. Am I right in drawing to this conclusion?

Many thanks
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,515
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 523
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: adding further functionality to a java program

 
1
  #7
Oct 27th, 2008
Yes, it's possible to "add further functionality" by composing new classes of your own that use those classes internally to extend or alter the functionality (assuming there are not licensing issues). Of course, you do need to understand the API of the other classes if you expect to do much with them, which was s.o.s's point.

If you stop to think on it a moment, you do this any time you write a program with the JDK. You utilize the existing classes in the API to build new ones of your own that offer some intended functionality.
Last edited by Ezzaral; Oct 27th, 2008 at 8:05 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 60
Reputation: Grub is an unknown quantity at this point 
Solved Threads: 0
Grub Grub is offline Offline
Junior Poster in Training

Re: adding further functionality to a java program

 
1
  #8
Oct 27th, 2008
Your comments are very much appreciated.

I thank you all.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 596 | Replies: 7
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC