Java Help - JAR File

Dear Experts,

I have a jar file with 2 main classes. I want to execute the jar file specifying some input to start with different main program at different times. How to do that?

package order:

It is packaged into classes.jar.

Best Regards.
LVL 15
Who is Participating?
objectsConnect With a Mentor Commented:
java -cp classes.jar com.utility.mainclass1

java -cp classes.jar com.utility.mainclass2
ksivananthConnect With a Mentor Commented:
write a batch/script file, which takes the input and launches the appropriate class!
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

StealthyDevAuthor Commented:
Can you please send the content of batch file?

I normally use:
java -jar jarname.jar
StealthyDevAuthor Commented:
Thanks to objects and all other experts who replied in seconds..

Thanks again!

Solution I have used:
java -cp classes.jar com.utility.mainclass1
java -cp classes.jar com.utility.mainclass2

ops, soory! :-)
First of all get familiar with MANIFEST.MF file and you will fix this.
StealthyDevAuthor Commented:
@Veleri: How to specify multiple Main Class in MANIFEST.MF ?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.