英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论