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):
I got this error, and it was because I had the arguments in the wrong order:
java maui.main.Examples tagging -jar maui-1.0.jar
java -jar maui-1.0.jar maui.main.Examples tagging
Try
java -cp .:mail-1.4.1.jar JavaxMailHTML
no need to have manifest
file.
I'm not sure I believe your symptoms:
jre
command isn't found, then running jre -cp app.jar
should give the same errorI'd expect you to see this error if you run:
java -jar app.jar
The Main-Class header needs to be in the manifest for the JAR file - this is metadata about things like other required libraries. See the Sun documentation for how to create an appropriate manifest. Basically you need to create a text file which includes a line like this:
Main-Class: MainClass
Then run
jar cfm app.jar manifest.txt *.class
I faced the same problem. This unix command is not able to find the main class. This is because the runtime and compile time JDK versions are different. Make the jar through eclipse after changing the java compiler version. The following link helped me.
http://crunchify.com/exception-in-thread-main-java-lang-unsupportedclassversionerror-comcrunchifymain-unsupported-major-minor-version-51-0/
Try running the jar created after this step and then execute it
If your class path is fully specified in manifest, maybe you need the last version of java runtime environment. My problem fixed when i reinstalled the jre 8.