943,729 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 768
  • Java RSS
Oct 27th, 2008
0

adding further functionality to a java program

Expand 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?
Similar Threads
Reputation Points: 14
Solved Threads: 0
Junior Poster in Training
Grub is offline Offline
60 posts
since Oct 2007
Oct 27th, 2008
0

Re: adding further functionality to a java program

Click to Expand / Collapse  Quote originally posted by Grub ...
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
Reputation Points: 919
Solved Threads: 354
Nearly a Posting Maven
stultuske is offline Offline
2,487 posts
since Jan 2007
Oct 27th, 2008
0

Re: adding further functionality to a java program

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.
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Oct 27th, 2008
0

Re: adding further functionality to a java program

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.
Reputation Points: 14
Solved Threads: 0
Junior Poster in Training
Grub is offline Offline
60 posts
since Oct 2007
Oct 27th, 2008
1

Re: adding further functionality to a java program

>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?
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Oct 27th, 2008
0

Re: adding further functionality to a java program

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
Reputation Points: 14
Solved Threads: 0
Junior Poster in Training
Grub is offline Offline
60 posts
since Oct 2007
Oct 27th, 2008
1

Re: adding further functionality to a java program

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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Oct 27th, 2008
1

Re: adding further functionality to a java program

Your comments are very much appreciated.

I thank you all.
Reputation Points: 14
Solved Threads: 0
Junior Poster in Training
Grub is offline Offline
60 posts
since Oct 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Tabula framework : REST Server & REST Editor alpha version 0.50
Next Thread in Java Forum Timeline: while loop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC