Can't execute jar- file: “no main manifest attribute”

后端 未结 30 1880
不知归路
不知归路 2020-11-21 22:30

I have installed an application, when I try to run it (it\'s an executable jar) nothing happens. When I run it from the commandline with:

java -jar \

30条回答
  •  清酒与你
    2020-11-21 23:06

    You might have the same problem as I do. After creating your .jar file, write jar xf app.jar META-INF/MANIFEST.MF. This will create a copy of the file to your current directory so you can read it. If it only says something like:

    Manifest-Version: 1.0

    Created-By: 1.8.0_51 (Oracle Corporation)

    and does not contain the "Main-Class" declaration, then I think you found your problem.

    I do not know how to solve it, though. I checked other people with same/similar problems on StackOverflow and couldn't find an answer. However with this information you can perhaps get some better help (given the fact that you have the same problem as I).

    Edit: I had tried with a manifest-file but didn't get it to work, but my mistake was to only name one of the classes when creating the jar-file. I wrote *.class instead and it works now.

    Although I don't know why there is a need to create a manifest-file. But I guess it's fine as long as it works.

提交回复
热议问题