• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Question about properties file

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Do I understand my assignment (UrlyBird) about properties file correctly?
For example if the properties file doesn't exist, the Configuration dialog will appear. The user enter the information depends of the startup
mode (database location, or IP or Port). Than the properties file will be created and all entered information from the user will be saved.
If the user starts the second time the application (server, or client, or the standalone) the programm looks if the properties file exists. If
this exists the application will be started with the parameters from the properties file without the Configuration dialog .
If some properties values are not defined. The Configuration dialog appears.
The user can modify this properties file also from gui:
for Standalone/Remote Client the properties can be changed in the main GUI, where I make the booking or search.

for Server the properties can be changed in GUI where I have only one "stop" button.

How do you think is it "as right as rain"? Did I understand it correctly?

Thanks a lot for your comments!
Regards
Olena
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My understanding of the properties file is that it is to be used for any GUI configurations associated with your client (or server also). However, I am using it to store the database file locations (for the server and standalone client) and remote hosts and ports (for the remote client). I would imagine that you should show a startup dialog of somekind for the database location or remote server regardless of whether the properties exist in the properties file or not. This way the user can change these properties configurations if desired before starting up. Of course changing properties from the client GUI (or server) would be recommended too.

One question I have: my specs say that the properties file "must be located in the current working directory.". Would that be the directory from which the program is running? If so, that sounds like it should be in the suncertify.db package. Does that sound correct?

Any input is appreciated. Thank you.
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Olena,

You are right as rain! That is almost exactly the same way I implemented mine.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would imagine that you should show a startup dialog of somekind for the database location or remote server regardless of whether the properties exist in the properties file or not.

I actually implemented mine the same way as Olena described, and did just fine. There is nothing, however, that says you cannot do it your way though. I have implemented both in real world situations. I would recommend filling in the dialog field with information from the properties file though... it makes it much easier on the User.

One question I have: my specs say that the properties file "must be located in the current working directory.". Would that be the directory from which the program is running? If so, that sounds like it should be in the suncertify.db package. Does that sound correct?

The current working directory is the one that you executed the application from, i.e. the directory you are in when you type "java -jar runme.jar". When you submit your assignment, it must be in jar form. Therefore you would not be able to write to a datafile that is in the suncertify.db package. Also remember that you cannot require that the properties file exists at startup, as assessors have been known to remove it...
 
David Sham
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it, I think. Should the properties file be put into the java classpath? The classpath would be retrieved as: Sound right, or am I way off? Thanks.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Should the properties file be put into the java classpath?



No. Take a look at Paul's reply above.

Perhaps an example might help:

In the example above, the current working directory is c:\temp. The runme.jar file is in a different directory (c:\scjdProject), and we cannot tell from that command line where the database file is - it could be in third, completly unrelated, directory.

Regards, Andrew
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you create a File with a name only, this would be represent a file within your current working directory by default. If you explicitly want to know your current working directory, have a look at the java.lang.System documentation, specifically under getProperties(), it is called "user.dir"
 
David Sham
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you both for your replies. Yes, I just learned from a friend that all you need do is instantiate a FileInput/OutputStream object with the filename and the first place it will look is in the current working directory. That's it. Then use that Input/OutputStream object to load/store your properties hashtable. I also just missed the user.dir key in the java.lang.System specs in the API. It was late last night and I was too tired to see it I guess. My code should actually be more simple now. Thanks a lot!
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic