简体   繁体   中英

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**

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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM