This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes persistent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "persistent" Watch "persistent" New topic


Andy Zhu
Ranch Hand

Joined: May 26, 2004
Posts: 145
I am trying to understand this requirement. Given the arrangement of the jar submission, it can behave in 3 modes and each should have a different setting associated with. however, if this jar executed in same location 3 times for different mode. Should I preserve the previous 2 settings so that any other run of a mode will conform to the setting it contains? The will clear previous settings in the file.

No other thread in the forum has brought this question. So I assume that I may misunderstand something. Any comments?


--------<br />Andy Zhu<br />scjp 1.4<br />scjd 1.4<br />SAS Certified Programmer 9.0
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
My understanding is that as long as the client/server program(s) are run from the same directory, we preserve the previous settings. ( to be saved/retrieved from the current directory)
Andy Zhu
Ranch Hand

Joined: May 26, 2004
Posts: 145
Thanks for your reply. But I may not state clear about my concern. Say, the jar file is in ./

first, we run java -jar ./runme.jar server
This time, the properties will store, say, db location=./db.db and port=1099.

Next we run java -jar ./runme.jar alone
This time, the properties will store file location=../db.db. However, at this moment should I preserve the db location and port properties so that the next time the program running as server it will have the properties as the last time it ran as a server?

I may misunderstand you. Would you say I should preserve the server properties in this case?
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
Yes. That is the whole point of file. Isn't it?
We store the information that was last used/entered by the user to run the application. Instead of maintaining 3 different file, We share only 1 file for the 3 modes.We can have different properties for server, client and the application in local mode but we persist them all to the same file.

For example:



Everytime you load all the properties from the file and store them back with the modified new ones.
Andy Zhu
Ranch Hand

Joined: May 26, 2004
Posts: 145
Hi, Vishwa:

Thanks for your comments. Now I am crystal clear about this requirement. I think the solution is quite easy. Well this is part of our reality about this assignment: guessing the real meaning of the specification, which really turns out many interpretations and which in turn confuse a developer in many of these interpretations. I feel really lucky I came to this forum at the begining when I started my assignment.

Thanks for all your helps.
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
I have a question related to this issue. Should we create the proporty file in binary format, or test format.

SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Denis Spirin
Ranch Hand

Joined: Mar 22, 2004
Posts: 72

there are no restrictions on property file in instructions. I think its better to use Properties API.

Regards<br /> <br />Ph.D.<br />SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD 2
I agree. Here's the link:
subject: persistent
Similar Threads
server/alone command line
What is this Properties File?
How many files should I have?
NX: Assignment questions
The mode flag