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.
SCJP 1.4<br />SCJD 1.4
Originally posted by Vince Cheung:
1. My first question is can I get configuration from properties.txt and don't let client to config it via GUI? I use sockets so I must use "serverPort" which is the port number of server to create socket at client side. Server side must config it into properties.txt. If I config it via client GUI, it will has a big chance to be different from configging by server.
2. My second question is which directory is the current working directory?
my tree is:
1. My first question is can I get configuration from properties.txt and don't let client to config it via GUI? I use sockets so I must use "serverPort" which is the port number of server to create socket at client side. Server side must config it into properties.txt. If I config it via client GUI, it will has a big chance to be different from configging by server.
2. My second question is which directory is the current working directory?
Mike<br />SCJP SCJD
Originally posted by David Abramowicz:
In this case the user is recommended to edit the config file through the GUI and then restart the application...
Does this approach violate any MUSTs?
Thanks /Dave
SCJP 1.4<br />SCJD 1.4
Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.
Current working directory is just where your runme.jar is.
Originally posted by Vince Cheung:
I have a doubt which is "a file called suncertify.properties". What's the meaning of "suncertify"? Is "suncertify" a directory or others?
Originally posted by Vince Cheung:
But Mike says "Current working directory is just where your runme.jar is."
I can't understand.
Originally posted by Matt Sheehan.:
Peter's answer is the correct one. Whatever directory you are in when you call "java -jar <path/>runme.jar <flag>" is your current working directory.
Originally posted by David Abramowicz:
I definetly see your point... However, say I update my user manual to this:
If you want to administer the server, do so by using the client in networked mode. After the server has been configured start any servers, clients or standalone applications.
I think I could live with that as a user and an administrator of the service. I mean it's not as if the data file location changes every fifteen minutes...
I'm not trying to get out of writing extra code, promise I just don't see much point with having a GUI for the server... What else do you stick in there, maybe it's something I've missed.
Thanks /Dave
Originally posted by Koen Serneels:
Well, if you put all the server configuration in the client GUI configuration pane, you are creating a obscure situation. You should doucment that they first configure the 'server - server settings' which are the actually settings (port etc) for the server. then they have to configure the 'client - server settings' which will be the same as the 'server-server settings' because this is the server the client is conneting to. But, you cannot make just one 'server configuration' because what if they want to start multiple servers ... I know, its not a must but it is just not a logical way to do it.
For the server I would create a very simple jframe with a textarea, start/stop button and a File->Configure... jmenu. Agreed, it is some extra programming, but hey, it are like 4 components, some text and some actionlisteners. The configure uses the same properties file as the client gui does, but edits other properties (client properties start with "client.something" server properties with "server.something") . So, what do you print in the textarea ? some usefull debug information, like 'starting server...' binding remote interface <database>...' . Or when the port is allready in use you say 'Server stoped. Port allready in use. please configure another port and restart the server' .
I know its not much. but doing it this way solves the configuration weirdness and I have to admit, a jframe looks nicer then some dark DOS shell...
SCJP 1.4<br />SCJD 1.4
Originally posted by Koen Serneels:
Ok, so basicly they mean that you put the properties file in the same directory as the jar file ? Which is in this case the root of the assignment...
When someone takes out the jar file and places it somewhere else (lets say c:\temp) they als have to copy the properties file beside it.
When a program runs under the UNIX or the Windows NT operating system there is a directory where the program is started. This directory is not necessarily the directory where the executable code is or where the basic program is. Sloppy saying: this is the directory where the user prompt was when the user typed in the command line starting the program. This is called the current working directory.
Originally posted by Daniel Simpson:
I think multiple servers is definitely past the scope of this assignment. For this assignment, it seems redundant, too, to configure the server using the server, and configure the client connection to the server when launching the client. Remember, when configuring the suncertify.properties file, you can configure it, but you will need to restart your app for the new changes to take place. My approach, a simple server GUI frame that allows you to choose the port and IP address of the server, and it persists it to the suncertify.properties file. Then, the client GUI runs, and reads in the values from the newly persisted properties file. Just an idea.
Originally posted by Matt Sheehan.:
[QB][/QB]
Originally posted by Koen Serneels:
What you are saying is basicly that the cwd is only defined at runtime. When packaging the assignment we cannot possibly know what the cwd is going to be. This comes down to the fact that we must assume that no property file is present and create one first if it isn't.
So when you launch the gui you load the configuration. The configuration system will first check if there is a property file in the cwd. If there is none, it will create an empty one and popup the configuration panel automatically asking to define the configuration parameters. Upon exit this information is saved to the property file in the cwd.
When there was a property file present in the cwd, the application starts silently and the configuration information is visible/changeable when the configuration panel is opened on request from the file menu.
Originally posted by Koen Serneels:
So the fundamental question is, is the assignment automatically failed when we supply an extra file the root ? (note that the file is not really required, when they delete it it will still work. It is just for convinience when they do start from the assignment root as cwd)
Originally posted by David Abramowicz:
I don't think the server port and IP should be set ONLY from the server. What happens if the server and the client are on different hosts?
Also, I can understand why you may want to set port server-side... But IP-address, hm... Can't really see why I would want to do that. Maybe if I have multihomed machine... Ah well, now I'm just pondering over nitty-gritty details.
Anywho, I'll be quiet and implement a little JFrame for the Server... Could as someone said be nice also to have it print some debug info as well as the whole db path thing, despite the fact that is not a MUST
Thanks /Dave
SCJP 1.4<br />SCJD 1.4
Originally posted by Daniel Simpson:
Now you got me wondering....can someone who has passed the exam please help me with this? Should we assume that the server and client are on the same machine? For instance, say I configure the server when the server launches and it persists the data to the suncertify.properties file. If the server and client were on different machines, how would the client know what ip address and port to connect to? This has me absolutely baffled. Someone who has passed the assignment, your help is greatly appreciated and welcomed! Thanks!
Should we assume that the server and client are on the same machine?
If the server and client were on different machines, how would the client know what ip address and port to connect to?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog