Reputation: 4949
I am looking to create a jar file in the current directory.
I did this in command line:
jar cfe MyApp.jar MyApp MyApp.class
Alternatively, i put the following into Mnf.txt:
Main-Class: MyApp.class
and ran
jar cfm MyApp.jar Mnf.txt MyApp.class
When i try to run it with
java jar MyApp.jar
I get the following error in both cases:
Error: could not find or load main class.
Mnf.txt & MyApp.class is in the current directory.
There`s no package definition in MyApp. Everything is in the current directory.
I`ve seen How can I convert my Java program to an .exe file? among others.
No idea what i`m missing here.
//===================
ADD:
Changing the content of Mnf.txt to:
Main-Class: MyApp
didn't change anything. i'm getting the same error.
Upvotes: 0
Views: 788
Reputation: 23982
Use
java -jar MyApp.jar
to run the main class in the jar
jar cfe MyApp.jar MyApp MyApp.class
java -jar MyApp.jar
Upvotes: 0
Reputation: 75346
Do not add ".class" to the name of the class in the manifest.
Java differentiates rather strongly between names of files on disk and class names.
Upvotes: 1