Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Java in General and the fly likes Jar - more than 1 main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Jar - more than 1 main" Watch "Jar - more than 1 main" New topic

Jar - more than 1 main

Lars Christian Hansen

Joined: May 05, 2005
Posts: 9

suppose I have an application with more than 1 main class. I have jar'ed the file and now depending on the situation, wanna be able to call on or the other main class. Is that possible via the command line?

I was thinks something in the lines of(TR.class is one of the main classes):

java -jar AppName.jar TR

But doesn't seem to work


Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

java -classpath AppName.jar TR

[Jess in Action][AskingGoodQuestions]
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 691
The command: java -jar ...
uses the contents of the jar file's manifest Main-class entry. There is only one per jar file.
I agree. Here's the link:
subject: Jar - more than 1 main