更新时间:2023-09-19 17:38:04
使用 java -cp Main.jar main.Main
,-jar
用于捆绑的 jars清单说明将哪个类用作主类.您对 -cp
(以及在您的 ant 构建文件中)所做的只是将它放在主路径上:您将 main.Main
指定为主类明确地,不在清单中.
Use java -cp Main.jar main.Main
, -jar
is for bundled jars with a Manifest saying which class is to be used as the main class. What you're doing with -cp
(and within your ant build file) is just putting it on the main path: you're specifying main.Main
as the main class explicitly, not within a manifest.
您还应该将其他 jar 放在类路径上(例如 -cp lib/example1.jar:lib/example2.jar:Main.jar
).根据与 **/*.jar
匹配的内容,可能有很多.
You should also put the other jars on the classpath (e.g. -cp lib/example1.jar:lib/example2.jar:Main.jar
). Depending on what matches **/*.jar
, there may be a number of them.