Java Help - JAR File

Posted on 2010-09-08
Medium Priority
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 200 total points
ID: 33624696
write a batch/script file, which takes the input and launches the appropriate class!
LVL 92

Accepted Solution

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

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

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 200 total points
ID: 33624726
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 200 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: 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.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

801 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