This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Properties packaging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Properties packaging" Watch "Properties packaging" New topic
Author

Properties packaging

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi all,
I've gone through these two threads NX :-P ackaging suncertify.properties and Properties Files and ResourceBundle. I would like to know whether my conclusions are all correct.
Somewhere in those threads it says:
runme.jar is for both client and server, that optional mode argument determines what runs.
so "java -jar runme.jar" will run your GUI but attempt a network connection, "java -jar runme.jar alone" will run in standalone mode, and "java -jar runme.jar server" will run your server.

I have no doubts about that. The specs are clear.
I also presume that I should not pack a properties file into the JAR file I will submit ([spec] "The JAR file must have the following layout and contents in its root:"). This makes me believe the examiner will extract runme.jar and run the programs in the console.
The spec also mandates that all configuration information be stored in a file called suncertify.properties which must be locacted in the current working directory.
Conclusion:
The single file suncertify.properties stores all properties for client/server whether standalone or not. The file will therefore contain keys such as suncertify.db.datapath, suncertify.client.serverport, suncertify.server.port, etc.
When a program (i.e. client or server) is started for the first time, most likely it won't find a properties file because there is none -unless the examiner has created one himself ;-)
(In my case)Both server and client come with a GUI that allows to make persistent changes to the properties.
No further implications as only one program accesses a properties file at the time.
Please let me know whether I'm on the right track.
Regards,
Marcel
Min Huang
Ranch Hand

Joined: Mar 17, 2004
Posts: 100
Hi Marcel. That's exactly what I did. Just make sure that if somebody creates his/her own suncertify.properties file and it's not valid (for example, has "suncertify.client.serverport_number" instead of your "suncertify.client.serverport"), your program can handle it (either by creating a new properties file altogether or just adding the appropriate key/value pair).


SCJP 1.4, SCJD 1.4, SCBCD (Preparing!)
Michael Hartman
Greenhorn

Joined: Feb 01, 2004
Posts: 11
I also presume that I should not pack a properties file into the JAR file I will submit ([spec] "The JAR file must have the following layout and contents in its root:").

I would suggest not packaging your own suncertify.properties file. (At least, I'm not doing it.)
This makes me believe the examiner will extract runme.jar and run the programs in the console.

I disagree with this. An examiner will not extract your runme.jar. More than likely the examiner will run your program from a command line such as:
java -jar runme.jar server
to start the server, then
java -jar runme.jar
to start the network client.
This is suggested in my instructions which state:
When you submit your assignment, each part (client and server) must be executable using a command of this exact form:
java -jar <path_and_filename> [<mode>]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Min,
...for example, has "suncertify.client.serverport_number" instead of your "suncertify.client.serverport"), your program can handle it...

Oh sure, I'm specifically looking for the property with the name that I've defined. If it's not there - for whatever reason - I use a default value and save it right away in the file provided.
Regards,
Marcel
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Michael,
I disagree with this. An examiner will not extract your runme.jar. More than likely the examiner will run your program from a command line such as:

What I meant was: "The examiner will extract runme.jar FROM THE BIG JAR which may be called myCandidateID_scjd.jar or so and run it from the console" (as you and I in my first posting pointed out).
Regards,
Marcel
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Properties packaging