How do I start multiple main programs in a Java executable .jar? -


i'm writing program contains multiple packages in it. each package has own main program want launch simultaneously when .jar executed interpreter. seems simple question, when looked around, seems people using ants (which i've never used before) , other methods. there simpler way in eclipse compile .jar multiple launch configurations, better yet, there way hard code in?

if best way launch through ant. kind of ant script write if want launch... main programs in packets com.myapp.package1.main, com.myapp.package2.main, , com.myapp.package3.main. in advance!

the jar manifest allows optionally specify no more 1 main class. invoked when execute java -jar flag.

java -jar myapp.jar 

you may include multiple main classes in single jar, each (except optional 1 above) must invoked using -classpath flag , qualified name of main class specified.

java -classpath myapp.jar com.mypackage.app.main01 && \   java -classpath myapp.jar com.mypackage.app.main02 && \   java -classpath myapp.jar com.mypackage.app.main03 

the example above spawn 3 separate java vms, each in own process. obviously, not meet requirement 'executable jar'.

alternatively, may wish have 1 main method starts separate threads, there 1 process, concurrent execution.

ant not suitable choice solve issue. suspect want single main method spawns multiple threads. feel free provide more information on requirements.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -