.
└── src
├── META-INF
│ └── MANIFEST.MF
└── com
└── company
└── Main.java
主.java:
package com.company;
public class Main {
public static void main(String[] args) {
System.out.println("Hello");
}
}
清单.MF:
Manifest-Version: 1.0
Main-Class: com.company.Main
从 src 文件夹执行
javac com/company/Main.java
jar -cvfm out.jar META-INF/MANIFEST.MF com/company/*.class
java -jar out.jar
一切都好
但是如果从上面的级别:
javac src/com/company/Main.java
jar -cvfm out.jar src/META-INF/MANIFEST.MF src/com/company/*.class
java -jar out.jar
我得到:
Error: Could not find or load main class com.company.Main
Caused by: java.lang.ClassNotFoundException: com.company.Main
为什么会这样?