Java Help - JAR File

Posted on 2010-09-08
Last Modified: 2013-12-14
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.
Question by:StealthyDev
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 26

Assisted Solution

ksivananth earned 50 total points
ID: 33624696
write a batch/script file, which takes the input and launches the appropriate class!
LVL 92

Accepted Solution

objects earned 350 total points
ID: 33624725
java -cp classes.jar com.utility.mainclass1

java -cp classes.jar com.utility.mainclass2
LVL 40

Assisted Solution

gurvinder372 earned 50 total points
ID: 33624726
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 15

Author Comment

ID: 33624728
Can you please send the content of batch file?

I normally use:
java -jar jarname.jar
LVL 16

Assisted Solution

Valeri earned 50 total points
ID: 33624736
LVL 15

Author Closing Comment

ID: 33624745
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

LVL 16

Expert Comment

ID: 33624753
ops, soory! :-)
First of all get familiar with MANIFEST.MF file and you will fix this.
LVL 15

Author Comment

ID: 33624763
@Veleri: How to specify multiple Main Class in MANIFEST.MF ?

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 58
Best environment for cross platform web development? 5 69
ejb entity bean example 2 31
Java array 10 55
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question