0

I have created a jar file in eclipse and now I want to execute the jar file in command prompt.

How can I do that?

Magnilex
  • 11,584
  • 9
  • 62
  • 84
Charan
  • 1
  • 1
  • possible duplicate of [Java: problem running a jar file in command line](http://stackoverflow.com/questions/945962/java-problem-running-a-jar-file-in-command-line) – Mathias Müller Jan 14 '15 at 10:17

2 Answers2

0

Run this command from command prompt:

java -jar <JarName>.jar

Note: you will need to jar a file called META-INF/MANIFEST.MF in order to run the jar after compilation.

If you are creating the jar using Eclipse do this:

  • Go to file > Export > Java > Jar file (hit next)
  • Select your project and all the files you would like to jar
  • Type below the destination of the jar (e.g. c:\MyJar.jar) (hit next x2)
  • On the bottom Main class either hit browse and choose the class which contains main or type: package_name.class_name (wihch contains the main entry point)
  • Hit Finish
  • Go to the jar location in command prompt and run as i mentioned above
Mercury
  • 7,430
  • 3
  • 42
  • 54
  • Please post the error you are receiving when trying to run the command above. also see if you can run java -version from the location you are trying to run the jar and post what’s happening. – Mercury Jan 14 '15 at 10:31
0

When your creating jar file using eclipse While reaching JAR manifest specification enter main class

enter image description here

jones j alapat
  • 931
  • 3
  • 13
  • 26