wood burning stoves 2.0*
The moose likes Java in General and the fly likes Call_Method_Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Call_Method_Problem" Watch "Call_Method_Problem" New topic
Author

Call_Method_Problem

Nik lammar
Greenhorn

Joined: Nov 27, 2004
Posts: 18
Hi's and [ meToYou.HappyNewYear()]



I have a problem conserning a project of mine...
I have a "project.jar" archive that inside are many classes of the main project software that runs normally.Anyway,my questions are...

1)May I call a method of an "A.class" from "project.jar" that does not belong to the "project.jar" archive?

2)If the above question is not understandable, please I'm refreshing what I am meaning (Is the same but in different words): May I call the "A.class" from "Beta.class" by importing the string argument :
% java Beta A.class


How may I do this,please I am hoping for your help!

Thanks!

Nik lammar
Greenhorn

Joined: Nov 27, 2004
Posts: 18
...and I don't want to use JRMI...
I have found some resources on internet that talks about ClassLoader Interface,
but still doesn't work to me.
so please, If you can post me a simple example with Alpha.class and Beta.class as my example above, that would be helpful to me...

Thanks for your time..
Nik lammar
Greenhorn

Joined: Nov 27, 2004
Posts: 18
Sorry about the 3rd continue post My Question Is still NOt Answered...
I am posting again because i forgot to refer where are the infos I found
on net:
javaworld.com about the jini tutorial...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
to 1) Absolutely. As long as both classes are in your classpath, it does not matter whether they are in the same jar file or not.

to 2)
java Beta A.class


This doesn't work. You call a class by importing it in your source code, and then invoking the method. Again, the class must be in your classpath, and the method must be accessible to the calling class (which is governed by its public/protected/package/private qualifier).


Ping & DNS - my free Android networking tools app
Nik lammar
Greenhorn

Joined: Nov 27, 2004
Posts: 18
Hi, and thanks for the respond,
You reply me something that i was afraid of...
this is not working...(unfortunatelly)

My problem is that I wanna let the users of my application to develop some extentions of this only application writting Java code. This is difficult
because I must develop a whole framework beneth and give the instructions to the users about it to write code that extends my application without the main binary distribution be change of. You know, that many times some of the needs of users need more customization and I am talking about 2000 lines of code until now, that a user-developer that wants customization is very difficult for them. That was the main problem that I have, and I thought that something like this probably would help.

Anyway, IF you have any suggestion about it, please reply me again!

Thanks for your time!
Nik
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
Why don't you make the classes/methods a user/developer should use to extend your app public, and ship the javadocs -which describe how to use them- with it? As long as they have the jar file, they can simply include that in their classpath.

Or are you thinking about a plugin mechanism where your code needs to call routines users/developers have written?

Either way, using/calling your classes and methods is not a problem.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
You want to allow users to "extend" or "customize" your Java application? Can you explain what sort of extensions you have in mind? How sophisticated are your users? If we know what you have in mind, we can give better suggestions. Note, by the way, how far this topic has come from the first post in this thread. This suggests that rather than just asking a specific question taken out of your problem context, you should be brief but also always indicate what you are trying to do, what your goal and context are, in the first post.


There is no emoticon for what I am feeling!
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Plug-in designs always make Dependency Inversion pop up in my head. At about slide 20-25 that presentation has some pictures that might look like what you're trying to do.

You hit on the points of documenting how to extend your system and making it easy. Those are certainly challenges in designing the interfaces that any extensions must implement. I don't have any concrete suggestions except to keep the poor extension coder in mind. Oh, and keep those interfaces stable! Any time you change one you upset your whole extender community!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Nik lammar
Greenhorn

Joined: Nov 27, 2004
Posts: 18
Thanks all of you for your replies,

I think the extention policy in java s/w related distribution is something that all of us has get ,at least 1 time, in mind...

I know that maby the extention mechanism is something that needs attention because , as you said, if the extention mechanism is change, the extention community of the users-developers would messed up in s/w updating.

I usually use obfacators because, in a past project of mine, I saw changes on the source code, for customization, in many users that means:

=>someone changed the source code for his custom needs, and gave this to the others that they had many problems in their database due to this customisation of the code...

So,I am thinking about an extention mechanism that the customization can't give such problems, except the open-architect of the mechanism created by the users...

That's all,
thanks all of you!
Farewell
 
Don't get me started about those stupid light bulbs.
 
subject: Call_Method_Problem