I have created a JAR file in this way jar cf jar-file input-files
. Now, I\'m trying to run it. Running it does not work (jre command is not found):
The easiest way to be sure that you have created the runnable JAR file correctly, with the appropriate manifest file, is to use Eclipse to build it for you. In your Eclipse project, you basically just select File/Export from the menu, and follow the prompts.
That way, you can be sure that your JAR file is correct and will know to look elsewhere if there is still an issue. The process is described in full in FAQ How do I create an executable JAR file for a stand-alone SWT program?.
You can run with:
java -cp .;app.jar package.MainClass
It works for me if there is no manifest in the JAR file.
I was getting the same error when i ran:
jar cvfm test.jar Test.class Manifest.txt
What resolved it was this:
jar cvfm test.jar Manifest.txt Test.class
My manifest has the entry point as given in oracle docs (make sure there is a new line character at the end of the file):
Main-Class: Test
set the classpath and compile
javac -classpath "C:\Program Files\Java\jdk1.6.0_updateVersion\tools.jar" yourApp.java
create manifest.txt
Main-Class: yourApp newline
create yourApp.jar
jar cvf0m yourApp.jar manifest.txt yourApp.class
run yourApp.jar
java -jar yourApp.jar
I discovered that I was also having this error in NetBeans. I hope the following is helpful.
This was the problem I was getting because I had other "test" programs I was using in NetBeans and I had to make sure the Main Class under the Run portion of the Project configuration was set correctly.
many blessings, John P
If you using eclipse, try below: 1. Right click on the project -> select Export 2. Select Runnable Jar file in the select an export destination 3. Enter jar's name and Select "Package required ... " (second radio button) -> Finish
Hope this helps...!