0

I'm trying to run this Java GUI application but I'm not sure how to get it to run. The project is located here: https://gitee.com/gangshushu/v7/tree/master/admon_gui/one-jar.
My initial attempt was:

java -jar one-jar-ant-task-0.97.jar

But I end up with the error:

no main manifest attribute, in one-jar-ant-task-0.97.jar

Doing some search around, Failing to run jar file from command line: “no main manifest attribute”, I ended up running:

java -cp one-jar-ant-task-0.97.jar Main

But I end up with another error message:

Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main

Searching around gave me some information overload here: What does "Could not find or load main class" mean?

How do I run this Java program? This is my first time trying to run a jar file, and I'm a little stuck.
Am I trying to run the Java program the wrong way?

greybeard
  • 2,249
  • 8
  • 30
  • 66
Mark
  • 730
  • 1
  • 8
  • 22
  • Does this answer your question? [Can't execute jar- file: "no main manifest attribute"](https://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute) – Deepanshu Rathi Apr 20 '21 at 05:20
  • Given the name, it seems to be an ant-task, to be run from an Ant build script, it is not an executable program. It is unclear to me why you think this is an executable program. – Mark Rotteveel Apr 21 '21 at 16:21

1 Answers1

0

Your main class is in a package, you need to specify in what package to find your main class. Try the following command line: java -cp one-jar-ant-task-0.97.jar com.beegfs.admon.gui.program.Main

Hopey One
  • 1,681
  • 5
  • 10
  • Is there a default location where the main class lives? Running the command results in ```Error: Could not find or load main class com.beegfs.admon.gui.program.Main Caused by: java.lang.ClassNotFoundException: com.beegfs.admon.gui.program.Main ``` – Mark Apr 20 '21 at 03:41
  • Is that the main class you were trying to run? Is your main class packaged in the Jar? If you need to check, rename your jar as a zip and open with a zip tool. – Hopey One Apr 20 '21 at 03:47
  • No need to rename the file and use a _zip_ tool. The [jar](https://docs.oracle.com/en/java/javase/11/tools/jar.html#GUID-51C11B76-D9F6-4BC2-A805-3C847E857867) tool can also list the contents of a JAR file. And by the way, [WinRAR](https://www.win-rar.com/start.html?&L=0) can also display contents of a JAR file without the need to rename the file. – Abra Apr 20 '21 at 04:00
  • I unzipped it and there doesn't seem to be a Main file. Although it does have other java files – Mark Apr 20 '21 at 04:00