• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I call my obj in another program?

 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I have this line ctx.put("name", xobj ); in my program1 and I like to call xobj in another program how can I call it in program2(two seperate programs)?
Am I clear?
thanks,
Elahe
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please clarify your question.
Do you mean:
I have an object in a HashMap (or similar construct) in one program (object). I want to access that object from a different program (object). How do I do this?
Possible Answer:
The HashMap in the first program (object) either needs to be constructed with the proper access (public, protected, or default (package)), or you need to create a "get" method in the first program with the proper access (public, ...) that the second program (object) can access.
One scenario:


Making any sense? Getting any ideas?
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or do you mean:
I type "java Program1" in which I create an object such as an ArrayList.
Then I type "java Program2" in another DOS window and try to access the ArrayList you created in Program1
??

This senario is only possible if you persist your object (save it to the hard drive, for instance).
 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dirk you got my question right but I didn't get exactly what I have to add to my code?
Hope to hear from you so soon...
Thanks,
ELahe
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code examples above demonstrate exactly one thing you could do. Do you have a specific question?
 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it.
Thank you so much
 
Dirk Schreckmann
Sheriff
Posts: 7023
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic