• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

about jar problem

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you, Barend. i will try
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic