Forums Register Login

about jar problem

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
thank you, Barend. i will try
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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)

 
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
One jar. You must point to a class that can differentiate between your command line arguments and start the application in the correct mode.
+Pie Number of slices to send: Send
 

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).
Everybody! Do the Funky Monkey! Like this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 824 times.
Similar Threads
three mode ?
Packaging the assignment (comments)
packaging
RMI: net.ConnectException
RMI: java.net.ConnectException: Connection refused
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:10:57.