wood burning stoves*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes The mode flag 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 "The mode flag " Watch "The mode flag " New topic
Author

The mode flag

leo mari
Greenhorn

Joined: Nov 12, 2003
Posts: 15
Hi Ranchers,
I don't fully understand:
"The mode flag must be either 'server', indicating the server program must run, 'alone', indicating standalone mode, or left out entirely, in which case the network client and gui must run."
1) "server program must run" means "Start RMI Server" or "Switch to Network Mode"?
2) "network client and gui must run" means "Switch to Network Mode and open the UI"?
3)Should I add to UI a network/local switcher?

Thanks
Leo
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Hi Leo,
Welcome to this forum.

1) "server program must run" means "Start RMI Server" or "Switch to Network Mode"?

Your application is divided into two parts:
- Client part, where the GUI displays the Record info, and allows book on record.
- Server part, where the application access the database file (network or non-network).
Thus, the server program refers to the program that receives requests and access the database file, and then return (or reflect) the result in the Client GUI (the JTable).

2) "network client and gui must run" means "Switch to Network Mode and open the UI"?

What you need to do is:
When the user types the command java -jar runme.jar [mode], your program decides which part of the application to run (client or server), and display the appropiate GUI to capture the configuration input by the users.

3)Should I add to UI a network/local switcher?

I think it is not necessary to use a swicther, becos the command determines what mode should be run. And I simply assume that (written in my doucmentation) there will be only one single type of application run on the same machine, and if a user wants to switch from non-network mode to network mode or vice verse, he need to close the current application, and restart it into another mode by the command.
Hope this help.
Nick.


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
HaoZhe Xu
Ranch Hand

Joined: Nov 03, 2003
Posts: 222
Be careful, my assignment told me only command line [mode] switch is permit.


[url]Olnex.net[/url]
[SCJP 1.2, SCJD, SCWCD]
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
I think Nicholas' reply is correct and doesn't rely on anything other than the permitted command line argument. I'm uncertain about the cause for your concern. Perhaps I'm missing something?


Regards, George
SCJP, SCJD, SCWCD, SCBCD
leo mari
Greenhorn

Joined: Nov 12, 2003
Posts: 15
Thank you for reply, but I am still a little bit confused....
I have
- the server-side data managment system
- the client-side gui
(and the network connection between the two)

So, if the user types
- java -jar runme.jar -server
I'll display the GUI ready to ask host + port for RMI connection
- java -jar runme.jar -alone
I'll display the GUI ready to ask local db path
- java -jar runme.jar
I'll display the GUI and ?
... Mmmm.. may you plaese gimme some more hints?
How should I use my factory Data class (local/RMIremote) If i can't use command-line?
What is the meaning of 'network client and gui must run'? :roll:
Please help me again.
I think this could be useful to understand better:
"Programs must not require use of command line arguments other than the single mode flag,which must be supported. Your programs must not require use of command line property specifications. All configuration must be done via a GUI.
The mode flag must be either "server", indicating the server program must run, "alone", indicating standalone mode, or left out entirely, in which case the network client and gui must run.
Thank you !
[ January 07, 2004: Message edited by: leo marinangeli ]
[ January 07, 2004: Message edited by: leo marinangeli ]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11486
    
  94

Hi Leo,
Welcome to JavaRanch.

Perhaps this might help:
So, if the user types
- java -jar runme.jar -server
Dispay the GUI for the Server (allow the user to enter port for RMI Registry, possibly enter local db path for the server, any other server configuration items).
- java -jar runme.jar -alone
Display the Client GUI ready to ask local db path
- java -jar runme.jar
Display the Client GUI and ask for the host + port for RMI connection
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
leo mari
Greenhorn

Joined: Nov 12, 2003
Posts: 15
Thank you Andrew!
It was the confirm I was looking for.
Do you think I can implement a GUI useful for server and client at the same time?
For example using a JPanel that can show server or client request info,
selectable thru a subMenuItem in JMenu or somthing else.

Obviously, I 'll dynamically change the boolean
...

...
looking at what user typed.
Thank you
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11486
    
  94

Hi Leo,
Reusing your software components is nice - but you have to decide where the practical limits of that are.
My advice would be to experiment - see whether you can do this without making your code too bloated, and without making the interface cluttered and/or clumsy. If you can do it in a nice elegant way, then do so.
Regards, Andrew
leo mari
Greenhorn

Joined: Nov 12, 2003
Posts: 15
Andrew, thank you very much, your help was very useful.
leo
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Originally posted by Andrew Monkhouse:
Hi Leo,
Welcome to JavaRanch.

Perhaps this might help:
So, if the user types
- java -jar runme.jar -server
Dispay the GUI for the Server (allow the user to enter port for RMI Registry, possibly enter local db path for the server, any other server configuration items).
- java -jar runme.jar -alone
Display the Client GUI ready to ask local db path
- java -jar runme.jar
Display the Client GUI and ask for the host + port for RMI connection
Regards, Andrew

Hi Andrew, I am still confused with the statement "in which case the network client and gui must run". You said above that we are supposed to display the client GUI and ask for host + port for RMI connection. What I don't understand is the requirements say that network client and gui must run. From your statement, I understood that the gui is Clinet GUI, but what about the network client? Are we asking host + port for RMI connection for this sake only?
Please clarify me with the understanding of "network client". Thanks alot.
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Satish,
Originally posted by Satish Avadhanam:

You said above that we are supposed to display the client GUI and ask for host + port for RMI connection. What I don't understand is the requirements say that network client and gui must run. From your statement, I understood that the gui is Clinet GUI, but what about the network client? Are we asking host + port for RMI connection for this sake only?
Please clarify me with the understanding of "network client".

The application runs in one of three operating modes: standalone, server, and network client. There is a GUI associated with each of these operating modes. The client GUIs associated with standalone and network client mode are almost identical. The only difference between them is that the client GUI associated with standalone mode has a local database and is therefore interested in configuration parameters like database file location, while the client GUI associated with the network client mode has a remote database server and is therefore interested in configuration parameters like database server host and port. The server GUI is different from either of the client GUIs in that it is not involved in displaying database records. The server GUI is interested in configuration parameters like database file location and database server port.
So, what is the network client? When the application runs in network client mode it depends on a database server to perform any database operations. The network client therefore needs to know where the database server is (host name and port number) so that it can communicate with it. The network client GUI must allow the user to specify these configuration parameters (host name and port number). Once the connection to the database server is established the network client GUI looks nearly identical to the local client GUI (the client GUI that would be running if the application were in standalone mode).
Hope this helps,
George
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
George, I really appreciate very much for your patience in explaining things in detail.
Thanks alot.
Vrinda Werdel
Ranch Hand

Joined: Jan 03, 2004
Posts: 75
Hi George,
This is a very informative discussion. I have one more question.
1 .when we run 'java -jar runme.jar -server'
Is it safe to say the only the server part is up (starting the RMI reg. binding to RMI registry) and ready to listen to incoming connections?
2. When we run ' java -jar runme.jar -alone'
Both the GUI and the Server part of the application run in the same JVM? Pl. correct me if I am wrong.
3. when we run ' java -jar runme.jar' it effectively starts a GUI which has its own JVM and connects to another process runinng in a different VM across the network?
For this (# 3) to successfully execute, the Server part should already be running right? That is the remote interface should be registered with the RMI registry?
BTW, who will start the registry?

Regards
Vrinda
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Vrinda,
Originally posted by Vrinda Werdel:
For this (# 3) to successfully execute, the Server part should already be running right? That is the remote interface should be registered with the RMI registry?
BTW, who will start the registry?

Yes, The server should already be running before any of the network clients try to connect (otherwise they will get an error about which your network clients should inform the user).
I recommend starting the registry programmatically. Take a look at this thread for some ideas: Topic: RMI Binding on localhost
Hope this helps,
George
Vrinda Werdel
Ranch Hand

Joined: Jan 03, 2004
Posts: 75
Was I right on the first two counts George?
Vrinda
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Vrinda,
Yes. Guess I forgot to say that.
Hope this helps,
George
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Hi George and others, I thought that I understood this concept, but again was after doing a diff. part of the project. Please correct me if what I understood was wrong.
Originally posted by Vrinda Werdel:
Hi George,
This is a very informative discussion. I have one more question.
1 .when we run 'java -jar runme.jar -server'
Is it safe to say the only the server part is up (starting the RMI reg. binding to RMI registry) and ready to listen to incoming connections?
If this mode is selected and run, a GUI is shown. In this GUI all we can do is to configure the Server and exit right? I mean we cannot do any business specific operations right. The one and only purpose of this GUI or to say mode is to "Configure the Server, like port, host". Am I right?

2. When we run ' java -jar runme.jar -alone'
Both the GUI and the Server part of the application run in the same JVM? Pl. correct me if I am wrong.

In this mode, a GUI will be shown. In the first screen of the GUI, we select the database file location on the local machine. The second screen will show all the business we can do, like book a hotel, search the hotels and other business specific functions, right?

3. when we run ' java -jar runme.jar' it effectively starts a GUI which has its own JVM and connects to another process runinng in a different VM across the network?
For this (# 3) to successfully execute, the Server part should already be running right? That is the remote interface should be registered with the RMI registry?

In this mode, a GUI will be shown. In the first screen of the GUI, we have to give the server port, host and other configurations required for remote client. In the second screen, we can do all business specific activities, same as what we can do in the second screen of the alone mode, right?

BTW, who will start the registry?
In the last mode, once we select the remote server host and port numbers, it should automatically start the server and start listening right? I mean we need to hard code this part so that once this mode is selected the server starts automatically? Is this correct?

Regards
Vrinda

Please correct me if I'm wrong. Thanks.
[ February 23, 2004: Message edited by: Satish Avadhanam ]
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Satish,

1 .when we run 'java -jar runme.jar -server'
Is it safe to say the only the server part is up (starting the RMI reg. binding to RMI registry) and ready to listen to incoming connections?
If this mode is selected and run, a GUI is shown. In this GUI all we can do is to configure the Server and exit right? I mean we cannot do any business specific operations right. The one and only purpose of this GUI or to say mode is to "Configure the Server, like port, host". Am I right?
Yes. Yes. The GUI can also allow the user to shutdown the server.
2. When we run ' java -jar runme.jar -alone'
Both the GUI and the Server part of the application run in the same JVM? Pl. correct me if I am wrong.
In this mode, a GUI will be shown. In the first screen of the GUI, we select the database file location on the local machine. The second screen will show all the business we can do, like book a hotel, search the hotels and other business specific functions, right?

That's the right idea. Here are some more things to consider. Does the user always have to see the first screen? If you are using the suncertify.properties file to persist the user's selections, do you always have to show the user the first screen? Maybe the first screen only needs to be shown if there isn't a suncertify.properties file or if the entries in the suncertify.properties file are wrong (that is, they cause some sort of problem when they're used).
3. when we run ' java -jar runme.jar' it effectively starts a GUI which has its own JVM and connects to another process runinng in a different VM across the network?
For this (# 3) to successfully execute, the Server part should already be running right? That is the remote interface should be registered with the RMI registry?

In this mode, a GUI will be shown. In the first screen of the GUI, we have to give the server port, host and other configurations required for remote client. In the second screen, we can do all business specific activities, same as what we can do in the second screen of the alone mode, right?

Absolutely, the second screen in this mode is exactly the same as the second screen in alone mode (well, maybe one screen title says something about remote mode and the other says something about local mode, but other than that they're the same.) I have the same comment about the first screen as in the previous question.
BTW, who will start the registry?
In the last mode, once we select the remote server host and port numbers, it should automatically start the server and start listening right? I mean we need to hard code this part so that once this mode is selected the server starts automatically? Is this correct?
No, the server does not start automatically when the client runs. The application (in server mode) must be started on the server before the application (in remote client mode) is started on the client machine. Starting a client-server application is a two step process. First you start the server. Then you start the client. So, my answer to your last question about starting the server automatically is no.

[ February 24, 2004: Message edited by: George Marinkovich ]
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Thanks George, your detailed explanation made me very clear. Thanks a million!!
Rolf Johansson
Ranch Hand

Joined: Feb 25, 2004
Posts: 32
A point of clarification...presently I have Java applications. That is, 3 Java applications, each with their own main method.
1) A Java application is my server that instantiates my database class and listens on a socket port for incoming requests from clients. As a request comes in this application performs the database activity and returns the results over the socket to the client
2) A Java application that puts up the GUI for the user to use. This application takes the famous <mode> command line argument. If <mode> is absent, this program connects to the server (1) and sends requests to the server over a socket, and get responses back from the server. If <mode> is "alone" it instantiates my database class and performs database activity directly, based on GUI activity.
3) A small Java application with a GUI that is used to update suncertify.properties file.
What I am confused about is the term "programs" in the instructions:
"The executable JAR containing the programs. This must be called runme.jar."
An executable jar (AFAIK) can only have 1 Java application. So what do they mean by "programs"? Am I supposed to have just 1 Java application that acts as a (1)server, (2)standalone clinet and (3)remote client? Should I just merge my applications from above (1 and 2) into 1 application that read the command line argument and behaves accordingly?
Then how do I get the examiners to run my program that manages the suncertify.properties file?
Any help is appreciated!
- Rolf.
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Rolf,
Welcome to this forum.
Originally posted by Rolf Johansson:
A point of clarification...presently I have Java applications. That is, 3 Java applications, each with their own main method.

Your life will be much easier with a single application.

1) A Java application is my server that instantiates my database class and listens on a socket port for incoming requests from clients. As a request comes in this application performs the database activity and returns the results over the socket to the client

This will be a problem unless you can call this application as follows:
java -jar runme.jar server
That is, this application should be your runme.jar operating in server mode.

2) A Java application that puts up the GUI for the user to use. This application takes the famous <mode> command line argument. If <mode> is absent, this program connects to the server (1) and sends requests to the server over a socket, and get responses back from the server. If <mode> is "alone" it instantiates my database class and performs database activity directly, based on GUI activity.

This is fine, as long as this application is called runme.jar.

3) A small Java application with a GUI that is used to update suncertify.properties file.

You shouldn't have a separate application (that is, some application other than runme.jar). Such a capability, which is required, should be integrated into your single application.

What I am confused about is the term "programs" in the instructions:
"The executable JAR containing the programs. This must be called runme.jar."
An executable jar (AFAIK) can only have 1 Java application. So what do they mean by "programs"? Am I supposed to have just 1 Java application that acts as a (1)server, (2)standalone clinet and (3)remote client? Should I just merge my applications from above (1 and 2) into 1 application that read the command line argument and behaves accordingly?
Then how do I get the examiners to run my program that manages the suncertify.properties file?

The use of the word "programs" in the assignment instructions is very unfortunate. The word should not be plural. They might possibly be referring to individual *.class files as programs, but that is a very eccentric and misleading way to refer to *.class files, in my opinion. Assume for a moment that "programs" is replaced by "program", and the assignment instructions become much clearer and easier to understand. I would argue that having a single program is not inconsistent with the instructions (and in fact, is the only interpretation that makes sense). An executable jar can only have one program. So, 1, 2, and 3 should be merged into a single executable (called runme.jar). Then, you don't need to get the examiner to run your suncertify.properties file editor, because it's built into your single application.

[ February 26, 2004: Message edited by: George Marinkovich ]
Rolf Johansson
Ranch Hand

Joined: Feb 25, 2004
Posts: 32
OK, so I have 1 Java application (i.e. 1 program) that will run:
1) My server (when mode="server")
2) My client as stand-alone application, accessing the database directly (when mode="alone")
3) My client as a remote client, accessing the database via a socket connection to a server (when mode is not specified).
Now if my properties manager is also included in the 1 Java application how do I know to run it, if the only possible command line arguments are as specified above?
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Rolf,
Originally posted by Rolf Johansson:
Now if my properties manager is also included in the 1 Java application how do I know to run it, if the only possible command line arguments are as specified above?

I did a search in this forum for "suncertify.properties" looking for some of my posts on the subject. I came up with these two:
Topic: NX: About the db file
Topic: NX: Mode Flag Confusion
If you need a better explanation let me know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The mode flag