aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes about jar problem 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 "about jar problem" Watch "about jar problem" New topic
Author

about jar problem

Vince Cheung
Greenhorn

Joined: Dec 06, 2004
Posts: 16
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

Joined: Dec 07, 2004
Posts: 64
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.


SCJP 1.4, SCJD 1.4, SCWCD 1.3, ICSD:Websphere 5.1
Vince Cheung
Greenhorn

Joined: Dec 06, 2004
Posts: 16
thank you, Barend. i will try
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11509
    
  95

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


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

Joined: Dec 06, 2004
Posts: 16
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

Joined: Oct 31, 2004
Posts: 10
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.


"Large Vehicles Require More Room" - Highway 69 en route to Sudbury, Ontario
Vince Cheung
Greenhorn

Joined: Dec 06, 2004
Posts: 16
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

Joined: Oct 08, 2004
Posts: 63
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

Joined: Dec 07, 2004
Posts: 64
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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about jar problem