Link to home
Start Free TrialLog in
Avatar of elmakarge
elmakarge

asked on

execute a method which belong to jar file (a.jar) from another jar file (b.jar)

hi, i have a .jar file with a GUI (for example : ControlPanel.jar). i want to execute some other .jar files and some of their methods in ControlPanel.jar file.
for example : there is a icon on the ControlPanel.jar program's GUI. start a jar file (for example : game.jar) when i click the icon. after that there is a buton on ControlPanel.jar program's GUI, and when i clicked that buton, a method which is belong to a class of game.jar file have to execute.
and i sholud be able to control different .jar files from ControlPanel.jar file. i mean i should be able to add and remove .jar files from ControlPanel.jar.

how can i do that ?
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>  You just need to ensure called.jar is in the classpath of caller.jar

He said, that "...i should be able to add and remove .jar files from ControlPanel.jar...." so I guess this isn't feasible...

Well it would be if you placed any potential callees in the classpath
Spose so...

A dynamic "hot-deployable" class loader would be sexier though (in a purely code based way) ;-)

(but much more work of course)

Tim
Yep
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> You just need to ensure called.jar is in the classpath of caller.jar

No you don't.

http://www.javaalmanac.com/egs/java.lang/LoadClass.html
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't think that's what he wants...  He wants something like a "plugin" folder where he can drop jar files that get added to/removed from his classpath automatically...

I think...
>>No you don't.

?? Why not?
This question is answered as far as I can see, so I reckon some form of split should be applied...

Shame elmakarge didn't return after asking it... :-(