user3186565
user3186565

Reputation: 9

"Main class could not be found or loaded"

I made a jar file but when I test it I get a message that the Main class could not be found or loaded.

I have this code:

C:\trafficProject\src>echo Main-Class: Main >manifest.txt     

C:\trafficProject\src>jar cvfm trafficProject.jar manifest.txt     
added manifest

C:\trafficProject\src>java -jar trafficProject.jar
Error: Could not find or load main class Main

Can anybody help me?

Upvotes: 0

Views: 265

Answers (2)

snoopy
snoopy

Reputation: 26

the 'c' option means create (a new empty jar file). You need to add classes to the new jar file, i.e. add .class files in the argument list after manifest.txt. Or if you want to just update an existing jar file, use 'u' instead of 'c'.

Upvotes: 0

Joop Eggen
Joop Eggen

Reputation: 109547

The MANIFEST.MF should be in a subdirectory META-INF. Case-sensitive, all capitals!

Read the documentation, search in the internet. To overcome starter's problems.

Upvotes: 2

Related Questions