Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

passing object refernce

Thread view: 
micro - 20 Apr 2007 06:45 GMT
hi,
I have two java applications one of them is kind of a plug in to the
other .so I want to pass an object reference from the first one to the
other (the plug in) .
passing a copy of that object is not what I want , I need to pass the
exact object reference.
any one can help me
thanks.
Philipp Leitner - 20 Apr 2007 09:26 GMT
> passing a copy of that object is not what I want , I need to pass the
> exact object reference.

I figure that you mean that both these applications are running in
different address spaces (different VMs)? In that case it is for
obvious reasons not possible to simply pass a reference between the
applications - no application can "peek" into the address space of a a
different application. You have to using some kind of inter-process
communication technology (like RMI) to make these applications
communicate.

/philipp
micro - 20 Apr 2007 09:37 GMT
> > passing a copy of that object is not what I want , I need to pass the
> > exact object reference.
>
> I figure that you mean that both these applications are running in
> different address spaces (different VMs)?

each one of the two has  main() function , do they run in different
VMs?
santax - 20 Apr 2007 10:18 GMT
> > > passing a copy of that object is not what I want , I need to pass the
> > > exact object reference.
[quoted text clipped - 4 lines]
> each one of the two has  main() function , do they run in different
> VMs?

Y
Andrew Thompson - 20 Apr 2007 10:23 GMT
Philipp Leitner wrote:
>> > passing a copy of that object is not what I want , I need to pass the
>> > exact object reference.
[quoted text clipped - 4 lines]
>each one of the two has  main() function , do they run in different
>VMs?

It depends on how they are launched.  If boh are launched
from the command line, then yes.  OTOH, if one is launched,
and it calls the main() of the other, they should both be
running in the same VM instance.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

micro - 20 Apr 2007 10:58 GMT
> Philipp Leitner wrote:
> >> > passing a copy of that object is not what I want , I need to pass the
[quoted text clipped - 10 lines]
> and it calls the main() of the other, they should both be
> running in the same VM instance.

actually one of them (lets call A)launch and in some point it calls
Runtime.exec() to make the other(lets call B) star
B needs a reference to an object that is initiated by A
Philipp Leitner - 20 Apr 2007 11:12 GMT
> actually one of them (lets call A)launch and in some point it calls
> Runtime.exec() to make the other(lets call B) star
> B needs a reference to an object that is initiated by A

Runtime.exec() starts a new subprocess. AFAIK this subprocess will run
in it's own VM, just as if you had launched it yourself from the
command line.

/philipp
Andrew Thompson - 20 Apr 2007 12:25 GMT
micro wrote:
>> actually one of them (lets call A)launch and in some point it calls
>> Runtime.exec() to make the other(lets call B) star
[quoted text clipped - 3 lines]
>in it's own VM, just as if you had launched it yourself from the
>command line.

If that is the case (don't know, and could not be bothered
checking) it might be better to get an instance of 'B' and
call the main(), as I alluded to earlier.  In that case..
a) Both will be running in the same VM.
b) 'A' will have a reference to 'B', and can call the public methods.
(so B.setTheObjectOfInterest( theObject ) should work just fine.)

Signature

Andrew Thompson
http://www.athompson.info/andrew/

A. Bolmarcich - 21 Apr 2007 03:11 GMT
>> Philipp Leitner wrote:
>> >> > passing a copy of that object is not what I want , I need to pass the
[quoted text clipped - 14 lines]
> Runtime.exec() to make the other(lets call B) star
> B needs a reference to an object that is initiated by A

This may be a job for Java Remote Method Invocation.  Please the
the tutorial at

 http://java.sun.com/docs/books/tutorial/rmi/index.html

to determine if Java RMI supports what you what B to be able to
do with the object in the JVM running A.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.