简体   繁体   English

如何找到jar文件的清单类?

[英]How to find the manifest class of a jar file?

I have an application bundled in a jar file which I need to launch on Linux environment, but I am unable to figure out which class within this JAR file is the application's entry point. 我有一个捆绑在jar文件中的应用程序,需要在Linux环境中启动它,但是我无法弄清楚此JAR文件中的哪个类是应用程序的入口点。

I tried to run it on Windows CMD as below: 我尝试在Windows CMD上运行它,如下所示:

java -jar build21-jdk13.jar

It raised the following error: 它引发了以下错误:

no main manifest attribute, in build21-jdk13.jar

Any help would be highly appreciated. 任何帮助将不胜感激。

For a jar to be able to run with java -jar command, the YourJar.jar/META-INF/MANIFEST.MF file should be like: 为了使jar能够使用java -jar命令运行, YourJar.jar/META-INF/MANIFEST.MF文件应类似于:

Manifest-Version: 1.0
Class-Path: .
Main-Class: the.package.ClassWithMainMethod

In your case, the Main-Class property is missing. 在您的情况下,缺少Main-Class属性。
An alternative is to run the jar passing the main class as argument: 一种替代方法是运行将主类作为参数传递的jar:

java -jar build21-jdk13.jar the.package.ClassWithMainMethod

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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