• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

packaging runme.jar

 
Zhaozhe Ruan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,guys
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
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i call a main() from another main()?
 
Thirumurugan Mylrajan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic