File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes [URLyBird] What are the persistent properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "[URLyBird] What are the persistent properties" Watch "[URLyBird] What are the persistent properties" New topic
Author

[URLyBird] What are the persistent properties

Jean-Charles Wadja
Greenhorn

Joined: Aug 13, 2010
Posts: 5
Hi Guys,

My instructions states :

Application does not conform to instructions provided in the assignment.
The Instructions state:
All configuration must be done via a GUI, and must be persistent between
runs of the program. Such configuration information must be stored in a
file called suncertify.properties which must be located in the current
working directory.


I assumed these configuration info are
- Last db file location when running in local mode
- Last server address and port for the remote mode
- Default values for all 3 properties

Is this all or am i missing some ? I do not provide any GUI to the user to modify these. I only change them upon successful login and read them when the application starts.

This scares me a bit because when testing on a linux machine, I have to modify manually the /etc/hosts to bind the server name with its local IP, otherwise the client is not resolving the address. I 've detailed this in my choices.txt and user guide but I am wondering if I won't be marked down for this.
I am close to find a solution to that problem but it doesn't work quite yet and I need to submit my work very soon



Thanks

Sandrew
Sarah Archer
Greenhorn

Joined: Jul 25, 2010
Posts: 19
The properties that you are persisting sounds about right, but will depend on how you have coded your app. You state that you have not provided a GUI to modify these settings. If there is no GUI how are they changed?

It should not be necessary to have to modify your /etc/hosts to get the application to work correctly. Most people only seem to test all the components running on one machine - i.e. localhost. I doubt many people try to get the app to work correctly across a LAN. It is up to you to decide if running across a LAN is part of the requirements.

I would be very wary about putting in the User Guide and choices.txt that the user needs to modify the external environment. The design of the assignment, no command-line params other those specified, no configuration except via a GUI, is designed to make life easy for the examiners.

If you do choose to make the app run across a LAN, then there is a RMI solution to the issue that avoids the need to change /etc/hosts.


Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

Can you use the IP, loopback IP or localhost name? Can you ping the local name without the hosts modification? If the first lot work but not by PC name then it just sounds like a network/PC setup problem and not your software. You can't be responsible for the user's incorrect setup.

I think you really should have some kind of GUI for setting these things up. One of the main requirements of the application is to work as a client/server so the client are going to need to select the sever address and port. What happens if the user moves the server to a new IP address or the existing default port is already in use?

I had a default port but blank server IP/name and database location. When the application starts you get a properties window in which you can choose the above settings and once you click ok it will start the main application as well as save the settings as defaults for the next launch. It still shows the properties window every time it starts though. Obviously each of the three modes requires slightly different settings.


SCJA, OCPJP, OCMJD
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

Database location, server address and port number are the properties you need to persist between different runs of your application. You don't need a seperate GUI to change these properties (directly in the file), but you need of course some GUI to let the user change the configuration settings before starting the application.

You are not the 1st one with the Linux machine issue. Using the search engine you'll find a few other threads describing the same issue (e.g. here)


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Dmitri Cherkas
Ranch Hand

Joined: Mar 22, 2010
Posts: 40
"... All configuration must be done via a GUI, and must be persistent between runs of the program."
Roel wrote : Database location, server address and port number are the properties you need to persist between different runs of your application ... you need of course some GUI to let the user change the configuration settings before starting the application.

Roel, if i correctly understand your last reply on this topic, the whole process of managing of persistent data (data from file "suncertify.properties") must be :

1) suppose i have a file "suncertify.properties" with the following content :
server_ip = 10.10.10.10
server_port_number = 12345
database_location = C:/Temp/SCJD/

2) therefore, when client starts the application, the program access "suncertify.properties" and show to client via GUI the following default content :
server_ip = 10.10.10.10
server_port_number = 12345
database_location = C:/Temp/SCJD/

3) client changes, for example, server_ip to 11.11.11.11 and works with application, then client stops the application.

The question is : When the next time client starts the application will GUI of step "2)" has the content "10.10.10.10" (old) or "11.11.11.11" (new) (must i update my "suncertify.properties" at step "2)" or "suncertify.properties" has always the same content ?) ?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

You need to persist the properties between different runs. So 1st time you show some default. When user enters other settings (and these are valid) you save the new settings to the file. So on the next attempt the latest valid settings are shown by default.

To answer your question: 11.11.11.11 should be shown.
Dmitri Cherkas
Ranch Hand

Joined: Mar 22, 2010
Posts: 40
Thank you Roel for your reply !..

Another question : from my assignment instructions : "...configuration information must be stored in a file called suncertify.properties which must be located in the current working directory."

To explore where is the current working directory i used the following block in my ApplicationRunner class situated in the "gui"-folder ("...\Implementation_of_the_Assignment\Implementation\code\suncertify\gui") of certification project :

and the output is : "...\Implementation_of_the_Assignment\Implementation\bin".
The question is : Is the "...\Implementation_of_the_Assignment\Implementation\bin" current working directory and suncertify.properties must be situated there ?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

I used System.getProperty("user.dir"); to get the current working directory. I believe the location depends of the directory where the runme.jar is executed from.
Dmitri Cherkas
Ranch Hand

Joined: Mar 22, 2010
Posts: 40
Ou, yes, you are right... Now i can conclude that suncertify.properties must be in the same directory of the runme.jar, isn't it ?

Therefore the JAR file that i'll send to SUN will have the following layout and contents in its root :
...
code --> folder
docs --> folder
runme.jar --> file
suncertify.properties --> file
...

Am i right ?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

You are not supposed to include suncertify.properties with your submission. If the file does not exist (at 1st run) it's intended to be created (and show some sensible defaults to the user)
Dmitri Cherkas
Ranch Hand

Joined: Mar 22, 2010
Posts: 40
This approach is logical... and explains and simplifies many thinks... Thank you Roel.
S. Thakker
Ranch Hand

Joined: Aug 11, 2011
Posts: 45
(and show some sensible defaults to the user)


I do not quite agree with this... I dont think there is a sensible setting for port, datafile locatione etc... If the file doesnt exist, leave it blank, and persist the properties for the next run. I dont think it is necessary to guess where the db file should be stored.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

As sensible default I used blank for database location and server address; for the port number I used the default RMI port number. So I didn't guess at all, because that's indeed impossible to do.
Dmitri Cherkas
Ranch Hand

Joined: Mar 22, 2010
Posts: 40
"... the program must allow the user to specify the location of the database..."

Is "location of the database" mean that the user provides :
1) location as folder (f.e. "C:\SCJD\") and database file name is final static variable in the program with the value "db-1x1.db" or
2) location as folder and file name (f.e. "C:\SCJD\someFileName.anyExtension") ?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

I used folder and file name as the location of the database
Dmitri Cherkas
Ranch Hand

Joined: Mar 22, 2010
Posts: 40
And file name can be any name, f.e. :
1) database.txt;
2) db_1111.custom;
3) ecc.

the only control with file is "... magic cookie value. Identifies this as a data file", right ?
Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

I set the default file filter to *.db but allowed *.* to be selected too.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

Chris Zaremba wrote:I set the default file filter to *.db but allowed *.* to be selected too.

That's what I did too
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [URLyBird] What are the persistent properties