Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: runme.jar

 
joe black
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a little confused about this file. My instructions say the following:
When you submit your assignment, each part (client and server) must be executable using a command of this exact form:


Where the mode can be either "server", "alone", or left out entirely. Does this mean that if someone wanted to run the server on one machine they would type "java -jar runme.jar server", then on another machine type "java -jar runme.jar" to run the client that would connect to the server. If so, how would they change the port the server is running on? Or should it always run on 1099? And if someone wanted to run in standalone mode they would type "java -jar runme.jar alone" on the current machine?
 
Don Resnik
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,
I am glad you posted a question I think I can help you with, because you just helped me on the column names issue. Here is a link that should answer your question:
http://java.sun.com/developer/Books/javaprogramming/JAR/basics/run.html
basically you have to designate the 'Main-Class' in the Manifest that is created when you create the jar file. That is how the jvm knows what class to run when you type: java -jar runme.jar <mode>
Don
 
Don Resnik
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,
About the port number. I just noticed this recently, but it says in that part of the requirements that the settings (I took that as host, port, db file and RMIservice name) have to be read from a file called suncertify.properties and modified through a GUI. Up until I read that, I was passing in those parameters via command line. I used a JDialog for the GUI. Hope that helps.
Don
 
joe black
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So in that designated main class file I can just have a switch statement to run the appropriate code based on the mode?
 
Don Resnik
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just wrote mine and that is what I did (I used if ...else if) and it works great. I also included an option for 'properties' that would bring up the properties GUI.
Don
 
joe black
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see how I could use this main class to run the client in either mode (standalone, network client), but how could I run only the server? If I say new Server(), or new Client() in the body of one of the conditionals in the main class file, will it run the main() of the corresponding class?
[ December 24, 2003: Message edited by: Joe Black ]
 
Don Resnik
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,
main methods are always static all you would need to is ( if the name of your server class is DBServer)

DBServer.main();
That's what I did in my startup class if the user supplied the arg 'server'
Don
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic