如何在清单文件中指定入口点位置以运行jar文件?

huangapple go评论69阅读模式
英文:

How do I specify the entry point location in a Manifest-file to run a jar-file?

问题

I am trying to run a program I've downloaded ( https://github.com/ottiram/MMAX2 ) which comes as a jar-file on Ubuntu 22.04. When I do, it returns: "no main manifest attribute, in MMAX2.jar". When I check in /META-INF/MANIFEST.MF, that file only contains one single line, namely:

"Manifest-Version: 1.0".

No entry point is specified. When I searched for the main method by looking for "public static void main", I found it in the file /org/eml/MMAX2/core/MMAX2.class in the class "MMAX2" (not sure if the file itself and this class it contains are equivalent?). I assume that I need to specify the location of this method in the Manifest-file!? I tried that several times with different ways of notation, e.g. by adding the following two lines to the Manifest:

"Main-Class: MMAX2.MMAX2.main

Class-Path: MMAX2.jar /org/eml/MMAX2/core/"

But then, when I try to run the jar, it returns: "Error: Could not find or load main class MMAX2.MMAX2.main
Caused by: java.lang.ClassNotFoundException: MMAX2.MMAX2.main"

That also happened with other versions I've tried.
I am not super techy, especially not when it comes to Java. Everything I've tried so far was the result of me copying code I've found as an answer to similar questions. Maybe it's just a syntax problem? Or my entire approach is wrong? Any help is very much appreciated!

Summary: I thought the problem was that the main method can't be found from within the Manifest-file. So I tried to add the location of the main method to the Manifest-file, though I'm not sure if I've chosen the correct syntax.

英文:

I am trying to run a program I've downloaded ( https://github.com/ottiram/MMAX2 ) which comes as a jar-file on Ubuntu 22.04. When I do, it returns: "no main manifest attribute, in MMAX2.jar". When I check in /META-INF/MANIFEST.MF, that file only contains one single line, namely:

"Manifest-Version: 1.0".

No entry point is specified. When I searched for the main method by looking for "public static void main", I found it in the file /org/eml/MMAX2/core/MMAX2.class in the class "MMAX2" (not sure if the file itself and this class it contains are equivalent?). I assume that I need to specify the location of this method in the Manifest-file!? I tried that several times with different ways of notation, e.g. by adding the following two lines to the Manifest:

"Main-Class: MMAX2.MMAX2.main

Class-Path: MMAX2.jar /org/eml/MMAX2/core/"

But then, when I try to run the jar, it returns: "Error: Could not find or load main class MMAX2.MMAX2.main
Caused by: java.lang.ClassNotFoundException: MMAX2.MMAX2.main"

That also happened with other versions I've tried.
I am not super techy, especially not when it comes to Java. Everything I've tried so far was the result of me copying code I've found as answer to similar questions. Maybe it's just a syntax-problem? Or my entire approach is wrong? Any help is very much appreciated!

Summary:
I thought the problem was that the main-method can't be found from within the Manifest-file. So I tried to add the location of main-method to the Manifest-file, though I'm not sure if I've chosen the correct syntax.

答案1

得分: 1

我认为应该是 Main-Class: org.eml.MMAX2.core.MMAX2 而不是。

英文:

I think it should be Main-Class: org.eml.MMAX2.core.MMAX2 instead.

huangapple
  • 本文由 发表于 2023年6月21日 23:03:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76524717.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定