aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes FBNS: Command line params server/client local/remote modes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "FBNS: Command line params server/client local/remote modes" Watch "FBNS: Command line params server/client local/remote modes" New topic
Author

FBNS: Command line params server/client local/remote modes

Jonathan Gerrish
Greenhorn

Joined: Mar 25, 2003
Posts: 24
Hi,

I want to keep my assignment as simple as possible, so I want to specify the server/client and local/remote mode on the command line, my questions are:-

1) Does anyone use scripts (eg: startServer.bat, startClient.sh etc?) or should the user be expected to run the java command?

2) How many jar files? Does everyone package client and server code in a single jar file?

3) Does anyone use a single executable (java -jar) jar file, if so, how do you determine whether to run in client or server mode, since the allowed commandline params do not include a "mode" parameter.

4) If there are any startup errors in the client, eg: cannot connect to server, is it acceptable to log this error to the console?

5) Any thoughts about using a URL as a parameter to the DB? A file:// URL could indicate local mode, an rmi:// URL could indicate remote mode?

6) Does it seem acceptable to have two main classes, one for the client and one for the server, and executing the appropriate one on the command line,eg: java -cp assignment.jar suncertify.server.StartServer for example?

I'm nearly finished with the assignment and just a bit of tidying up todo, my startup currently uses one class with a main method, which has an abstract factory type method to instantiate an appropriate base class, but then I realised I can't pass a parameter like mode=server and can't think of another way to distinguish server and local client mode. I'd also written a fancy singleton configuration class (saves passing around command line params), but I think I will strip down to the bare bones and keep it as simple and uncomplicated as possible.

Any comments are would be really appreciated.

All the best, Jonathan.

[Andrew: Added FBNS to the title so you (hopefully) wont get posts telling you what the requirements are for the other certifications.]
[ June 25, 2005: Message edited by: Andrew Monkhouse ]
Jonathan Gerrish
Greenhorn

Joined: Mar 25, 2003
Posts: 24
I completely overlooked how easy it is to test the client(local/remote) and server modes....

if(paramPresent("host"))
{
// start remote client
}
else if(paramPresent("port") && !paramPresent("host"))
{
// start server
}
else
{
// start local client
}


Although this is doesn�t let you start the server with just the "data" parameter, if you wanted to start on the default port...

Otherwise maybe its just easier to have two separate Main classes, one for client the other for server?

Jonathan
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11484
    
  94

Hi Jonathan
Originally posted by Jonathan Gerrish
1) Does anyone use scripts (eg: startServer.bat, startClient.sh etc?) or should the user be expected to run the java command?

From the instructions
When you submit your assignment, you must ensure that it is packaged in such a way that it is completely clear how the examiner should run it using a java command line.


The way I read those instructions you cannot provide DOS batch files or Unix shell scripts (or ...). You must provide instructions so that the instructor can run your submission on any operating system.

Originally posted by Jonathan Gerrish
2) How many jar files? Does everyone package client and server code in a single jar file?
Personally, I had two jar files, although for a long time I was considering three - whatever makes sense to you.

Originally posted by Jonathan Gerrish
3) Does anyone use a single executable (java -jar) jar file
I think you answered this adequately yourself

Originally posted by Jonathan Gerrish
4) If there are any startup errors in the client, eg: cannot connect to server, is it acceptable to log this error to the console?
Yes, but I would also pop up a dialog box to tell the user what has happened, and hopefully give them some clues on how to fix it.

Originally posted by Jonathan Gerrish
5) Any thoughts about using a URL as a parameter to the DB? A file:// URL could indicate local mode, an rmi:// URL could indicate remote mode?[/url]Personally I dont think that a file:// is necessary, and may confuse users who have to enter the file:// URL with forward slashes on a Microsoft operating system. The rmi:// URL does have possibilities though.

Originally posted by Jonathan Gerrish
6) Does it seem acceptable to have two main classes, one for the client and one for the server, and executing the appropriate one on the command line,eg: java -cp assignment.jar suncertify.server.StartServer for example?
Certainly.

Originally posted by Jonathan Gerrish
Although [the solution in the second post above] doesn�t let you start the server with just the "data" parameter, if you wanted to start on the default port...
However if you were to make two of the parameters mandatory for server mode (say port number and data file name) then you would be able to get around that limitation.

Personally I went a different way - I created two separate executable jar files: one for the client and one for the server. Both used default values for everything, so it was not necessary for any command line options.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FBNS: Command line params server/client local/remote modes