找不到主类:运行Java Jar时?

时间:2014-05-15 19:43:14

标签: java linux jar

我在运行java Jar文件时遇到问题。我收到错误"无法找到主要类:com.body.Mouth。程序将退出。"

Valid (No error):
running Mouth class from eclipse. main function is in Mouth.


Invalid (could not find main class error):

    java -jar Eat.jar
    java -jar Eat.jar com.body.Mouth

感谢,

汉克

2 个答案:

答案 0 :(得分:4)

试试这个:

java -classpath PATH_TO_EAT.jar com.body.Mouth

答案 1 :(得分:1)

命令

java -jar Eat.jar

将尝试执行META-INF/MANIFEST.MF中找到的主类,如下所示:

Manifest-Version: 1.0
Created-By: 1.7.0_06 (Oracle Corporation)
Main-Class: com.body.Mouth

您可以详细了解如何创建执行JAR here