0

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.

Community
  • 1
  • 1
Roam
  • 4,831
  • 9
  • 43
  • 72

3 Answers3

1

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.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
0

There should be manifest entry: Main-Class: MyApp without .class

m-szalik
  • 3,546
  • 1
  • 21
  • 28
0

Use

java -jar MyApp.jar

to run the main class in the jar

jar cfe MyApp.jar MyApp MyApp.class
java -jar MyApp.jar
Ravinder Reddy
  • 23,692
  • 6
  • 52
  • 82