Two Laptop Bag*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes (B&S)Question regarding mode flags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "(B&S)Question regarding mode flags" Watch "(B&S)Question regarding mode flags" New topic

(B&S)Question regarding mode flags

Saheed Adepoju
Ranch Hand

Joined: Jun 23, 2004
Posts: 267
Hi all
I have a question that deals with the mode flags that the application exist with. The flags are server,alone and when nothing is typed.

But i guess there is a fundamental flaw in this mode. Given the above instructions, it is not possible to have the client run from another computer and connect to the server running on another machine because in order for both to run, one would have to use java -jar runme.jar and this according to the instructions would have to start the Configuration screen for one to set the Server name,port and Datafile location and then start the server. After this is done the client screen comes up and then one has to set up the client(i.e enter the server name and the port number). From the my instructions it follows that one cannot really test across a real network right? That is start the server on one machine and then start the client on another machine and test the connection.
The mode java -jar runme.jar server only starts the server and nothing else (right?). Then what is the use of starting it with the mode flag "server" when one cannot have a mode flag say "client" to allow one to connect to the started server?
The mode java -jar runme.jar alone start the client in local mode and no networking is done. This is fully logical and makes perfect sense.
I dont know if someone understands what i am saying? I just hope i am on the right track concerning my thinking of the mode flags. Thanks

Saheed Adepoju<br />SCJP 1.4<br />SCJD (B&S..In progress)
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
you're making the incorrect assumption here that the client and server are the same application.
They're not.

When you start it with the "server" flag, you start just the server on that machine.
When you start it with the "alone" flag, you start just the client without any network connections to anything (not even localhost to a locally running server, if you do that it's automatic failure).
When you start without flags, you start in networked mode and ask for a server to connect to.

If you run client and server on the same machine, you need to start the jar twice, once with the "server" flag, and once without it.

So you have 2 applications that are quite different but are started from the same jar file.
Both have their own Swing user interfaces, both will run in different JVMs, and they can very well run on different computers.

What I've done is the following:
1) create a Java application for the server, with its own main method and everything, that starts a Swing GUI if possible (and if not defaults to its config file or built-in defaults if that isn't available) to ask for port number, filename, etc..
2) create a Java application for the client that can either connect to a server or start an embedded server (depending on a checkbox or commandline argument).
3) create a Java application that depending on the commandline starts either one of these applications.

The actual database code (except the networking part) is a module which is used both by the server application and (in standalone mode) by the client application.

Saheed Adepoju
Ranch Hand

Joined: Jun 23, 2004
Posts: 267
Thanks for your swift reply! Ok let me get this straight! when u start the Application without mode flags, the client would lauch a window reqesting for the server to connect to and also the port number. So the "no flag" will launch a client application and ask for the necessary information for connection? And as long as the mode "server" is up and running, one can connect to that one?Am i right(i am sure i am). Anyways, i appreciate ur swift and quick response.Have a lovely day
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
Correct. Without any flags the client starts and asks for a database server to connect to.
It is sorta covered in the JavaRanch Style Guide.
subject: (B&S)Question regarding mode flags
Similar Threads
suncertify. properties -- Network / non-networked mode
NX Contractor - startup mode
Don't understand mode flag
The mode flag
NX: runme.jar