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
Joined: Feb 17, 2004
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.
Joined: Mar 06, 2006
can i call a main() from another main()?
Joined: Jan 26, 2006
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
Joined: Apr 21, 2006
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.