This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Running alternate class in jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Running alternate class in jar file" Watch "Running alternate class in jar file" New topic
Author

Running alternate class in jar file

Tom McAmmond
Ranch Hand

Joined: Feb 16, 2004
Posts: 58
I know that if I specify the main class in a jar file's manifest I can just run



But what if I have two classes in the jar file with a main() method, say a utility.class and a mainclass.class, and once in a while I want to run that utility.class instead? Is there a way to do that? Or do I have to remove the main-class from the manifest?

Thanks for any help
Tom McAmmond
Ranch Hand

Joined: Feb 16, 2004
Posts: 58
Forget it - I answered my own question. For the curious (because I always hated reading someone's question that was like mine that later only said "I figured it out"), you do it like this:

java -cp jarfile.jar classname
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Running alternate class in jar file
 
Similar Threads
Executable jar Failed to load Main-Class manifest attribute
jar
Ant - How to create a runnable jar of jars and classes
setting the classpath for java -jar
monkhouse's sample