jQuery in Action, 3rd edition
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes packaging runme.jar 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 "packaging runme.jar" Watch "packaging runme.jar" New topic

packaging runme.jar

Zhaozhe Ruan

Joined: Mar 06, 2006
Posts: 17
i'm on the track of packaging my stuff, but i have a question
for the executable jar file 'runme.jar', I need to start the programs as
java -jar runme.jar server;
java -jar runme.jar client;
java -jar runme.jar ;

but i have a main() class for client, and another main()class for the server
can I make two excutable jar files "client.jar" , "server.jar". and make them under the "runme.jar"

but when i do that, i can not use the form "java -jar runme.jar [mode]"

anyone can help me to resolve this? thanks
Oliver Weikopf
Ranch Hand

Joined: Feb 17, 2004
Posts: 58
No, you may not include a jar for each version or deviate from the given syntax. The instructions are very clear there.

Use one main only. If you find no appropriate class to put it into, you might want to add a class called Startup or something and give it nothin but a main method that calls the main() appropriate for the arguments.
Zhaozhe Ruan

Joined: Mar 06, 2006
Posts: 17
can i call a main() from another main()?
Thirumurugan Mylrajan
Ranch Hand

Joined: Jan 26, 2006
Posts: 64
Originally posted by Zhaozhe Ruan:
can i call a main() from another main()?

What Oliver means is that its good to have only one entry point as per the requirements given by Sun. If there is only one entry point creating the manifest file for the JAR is easy.

Create a dummy class with main() which will instantiate the client or server objects according to the paramaters passed. Dont have static main methods on these classes. Use Constructor overloading to pass appropriate paramaters.

Hope this is clear.

SCJP , SCJD. (IBM 142 in progress).
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
no, that's not what he meant.
public static void main(String[] args) is just another static method which you can call like any other static method.
So your launcher can call Client.main(args) or Server.main(args) from its own main method without instantiating anything.

I agree. Here's the link: http://aspose.com/file-tools
subject: packaging runme.jar
It's not a secret anymore!