Lifus
Lifus

Reputation: 13

Getting "Error: Could not find or load class" even though I have the Main-class defined in a Manifest File

I'm trying to build a jar file through the command line, and I'm running into issues.

Here are the contents of my jar file:

META-INF/
META-INF/MANIFEST.MF
bin/main/Main.class

and the contents of my MANIFEST.MF

Manifest-Version: 1.0
Main-Class: bin.main.Main

This seems to me like it should work, but when I try to run the jar file on command line using

java -jar -JAR.jar

I'm told

**Error: Could not find or load main class bin.main.Main**

Upvotes: 0

Views: 81

Answers (1)

Justin
Justin

Reputation: 1356

Make sure your Main.java has package bin.main; on the first line.

Seelenvirtuose adds that if the package is main, the class file must be put into /main/Main.class (not /bin/main/Main.class).

Upvotes: 2

Related Questions