Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

Possible Duplicate:
How to run a JAR file

How do we run a jar file in command prompt?

share|improve this question

marked as duplicate by Mark Elliot, Bala R, Michael Petrotta, WhiteFang34, AVD Apr 25 '11 at 3:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 333 down vote accepted

Try this

java -jar <jar-file-name>.jar
share|improve this answer
6  
this will work when the created jar file is a runnable jar. – Chetan Feb 23 '15 at 12:09

If you dont have a manifest in your jar invoking java -jar will not work.

Use this command if you dont have a manifest:

java -cp foo.jar full.package.name.ClassName
share|improve this answer
    
This also works if you want to run a different class main than what is specified in the manifest. – br3nt Jan 13 '16 at 1:30
3  
For Developers, I think this is a better answer than Bala R's, although they should ideally be combined – Penn Aug 8 '16 at 18:23

java [any other JVM options you need to give it] -jar foo.jar

share|improve this answer
12  
-D arguments go before the -jar! thanks I needed that – Clarence Liu Nov 21 '13 at 4:02

You can run a JAR file from the command line like this:

java -jar myJARFile.jar
share|improve this answer
    
well done for answering 2 seconds before the accepted answer :-) – Rich S May 15 '16 at 22:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.