This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Command Line Argument - Mode Flag 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 "Command Line Argument - Mode Flag" Watch "Command Line Argument - Mode Flag" New topic
Author

Command Line Argument - Mode Flag

Seetharaman Iyer
Ranch Hand

Joined: Jun 25, 2010
Posts: 35
Hi,

I'm bit confused with this statement. "
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.
"

Am I right on these?
1. We will be using same runme.jar to launch the application for three different mode(way) like one as server alone, and another as client alone and another one as client-cum-server (means process will do all the jobs)?

2. Just to check; when we pass,
a) "server" -> Only network server program should run - we have to launch client program separately using same runme.jar by not specifying anything in the mode flag; just by leaving it blank (either from different or same machine).

b) "alone" -> this type of launch will do both server side jobs as well as clients side jobs (means directly accessing DB file)

c) left blank -> Only network client program should run (i.e., GUI alone). Server must be started separately.

Thanks in advance,
Seetha...
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5126
    
  12

No need to be confused, your remarks are spot-on

the same jar (runme.jar) is used to run the application in 3 different modes (depending on a single argument):
  • "server": starts the network server
  • "alone": starts the stand alone client application
  • (no argument): starts the network client application (which has to access the network server to make changes to the database file)


  • SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
    http://www.javaroe.be/
    Seetharaman Iyer
    Ranch Hand

    Joined: Jun 25, 2010
    Posts: 35
    Thank you so much Roel for your timely help. You are a champ
    Ed Ward
    Ranch Hand

    Joined: Jan 30, 2006
    Posts: 147
    Follow up question: How to handle the situation where this is a first execution of the program (which means no properties file yet exists) and no argument is passed. If both the server and client apps are to startup (the client being in network mode), should we force the server to come up first before allowing the user to make use of the client gui?
    Seetharaman Iyer
    Ranch Hand

    Joined: Jun 25, 2010
    Posts: 35
    Follow up question: How to handle the situation where this is a first execution of the program (which means no properties file yet exists) and no argument is passed. If both the server and client apps are to startup (the client being in network mode), should we force the server to come up first before allowing the user to make use of the client gui?

    It's not necessary. It's all upto us how we want the things to be working. In my case, no matters server is already started or not, client (networked) can be launched and run. I allow the user to change the server's ipaddress and port details while it's running. So the only time when the user wants to search (& Reserve) only, I need to connect to the server to get (reserve) the details. Rest of the time, it just can simply run. No matters whether server got crashed. This option also enable the user to connect to the different server (by specifying ipaddress and port).
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5126
        
      12

    Ed Ward wrote:If both the server and client apps are to startup (the client being in network mode), should we force the server to come up first before allowing the user to make use of the client gui?

    How are you planning to force the startup of a jar on any random computer (ip unknown to you) in the company network?

    Your network client just starts, dialog shows, user enters configuration settings (ip + port) and if no server application is found a message wille be shown: "server not running"
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Command Line Argument - Mode Flag
     
    Similar Threads
    [NX Contractor] Package and run application
    NX:Question about MODE
    Running server/client separately in runme.jar
    The mode flag
    Command line argument - Mode Flag