• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about jar problem

 
Vince Cheung
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i do to start program by commond line?
java -jar suncertify.jar server (Starting Server)
java -jar suncertify.jar client (Starting Client)

thanks
 
Barend Garvelink
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to specify the main-class in the META-INF/MANIFEST.MF file inside the jar, when you do, the "java -jar" notation will work.
 
Vince Cheung
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you, Barend. i will try
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vince,

The JavaRanch SCJD Reading Materials has two links you might be interested in.

Under the tutorials and whitepapers section ...

Distributing your Application as an executable JAR file http://www.cs.princeton.edu/introcs/85application/jar/jar.html

Sun's RMI Tutorial: http://java.sun.com/docs/books/tutorial/reallybigindex.html#rmi

The first one probably answers your question perfectly.

Regards, Andrew
 
Vince Cheung
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still can't do it, Can someone say how to do detailedly.
thank you
How can i do to start program by commond line?
java -jar suncertify.jar server (Starting Server)
java -jar suncertify.jar client (Starting Client)
 
Isaac Shabtay
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vince Cheung:
I still can't do it, Can someone say how to do detailedly.
thank you


Define the main class to be, say, "suncertify.Main". Then, in suncertify.Main, analyze the argument and invoke the appropriate functionality.
 
Vince Cheung
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should I put all classes(server and client) in a jar file or in two jar files(one is server and one is client)??

I have tried to put all classes in a jar file. But I can't start by two commond down.
java -jar suncertify.jar server (Starting Server)
java -jar suncertify.jar client (Starting Client)

I can only start one of two classes(Server, Client)
Manifest-Version: 1.0
Created-By: 1.4.2 (Sun Microsystems Inc.)
Main-Class: suncertify.server.ServerUI (or suncertify client.HotelMain)


How can I do, please give me some help, thanks
 
Matt Sheehan.
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One jar. You must point to a class that can differentiate between your command line arguments and start the application in the correct mode.
 
Barend Garvelink
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vince Cheung:
Should I put all classes(server and client) in a jar file or in two jar files(one is server and one is client)??

The instructions state that the entire application should be in a single file named runme.jar (not suncertify.jar! but check your instructions file to be sure).

Originally posted by Vince Cheung:
I have tried to put all classes in a jar file. But I can't start by two commond down.
java -jar suncertify.jar server (Starting Server)
java -jar suncertify.jar client (Starting Client)

I can only start one of two classes(Server, Client)


How can I do, please give me some help, thanks


Take a look at the signature of the main method:


The key is in the "args" parameter. This will contain anything you type when starting the program (in this case: server or client).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic