Problem running a Jar file

前端 未结 2 1764
陌清茗
陌清茗 2021-01-23 05:22

I\'ve compiled a java project into a Jar file, and am having issues running it.

When I run:

java -jar myJar.jar

I get the following err

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-23 06:12

    In your manifest file, make sure you have the attribute Main-Class set to the name of the class containing your main() method. For example, if the package-qualified name of the class is my.cool.Class, then, in your JAR manifest, Main-Class should be set to my.cool.Class.

    Also made sure that you have a package declaration in your .java files (for example, in Class.java, make sure you have the proper package my.cool; declaration). Also, make sure your directory hierarchy is set up correctly (my.cool.Class should be in $SRC/my/cool/Class.java).

提交回复
热议问题