How to run java program in command prompt with jar




















Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Visit chat. Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings. After you finish the dialog, open your command prompt and cd to the folder containing the jar file you just generated.

Assuming its name is myproject. You may find that your program can no longer find its ParserLib grammar file, because it is trying to read it as a file relative to the project folder, and you are no longer running the program from your project folder.

A better way would read the grammar as a classpath resource , which allows the code to be packed up in a jar, along with the grammar file, and still be able to find the grammar. Solution: The solution for this issue is described below. You can create your jar without Main-Class in its Manifest file.

Then : Just need to pass the complete fully classified name of the class. Each JAR file have a manifest file by default. Although the default manifest file contains just two entries, but complex manifest files can have way more. MF: Manifest-Version: 1. Improve this question.

Community Bot 1 1 1 silver badge. Nirav Nirav 5, 4 4 gold badges 33 33 silver badges 44 44 bronze badges. Add a comment. Active Oldest Votes. Improve this answer. Bala R Bala R k 22 22 gold badges silver badges bronze badges. More times when you usea a '. Thanks : — user Using these command you can run the jar file using the background process. Use this command if you dont have a manifest or to run a different main class than the one specified in the manifest: java -cp foo.



0コメント

  • 1000 / 1000