java - 在 IntelliJ Idea 中,我的应用程序可以运行,但作为 jar 运行——不是因为 "Error: Could not find or load main class"

标签 java linux intellij-idea

我安装了java 1.7。在 IntelliJ Idea 中,我的应用程序可以运行,但是当我将其作为 jar 运行时,它返回一个错误:

$ java -jar my_app.jar 
Error: Could not find or load main class my_app.MyMainClass

如何解决?

最佳答案

您需要创建一个可执行的 jar。请参阅此页面,设置应用程序的入口点,了解更多详细信息:http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html

关于java - 在 IntelliJ Idea 中,我的应用程序可以运行,但作为 jar 运行——不是因为 "Error: Could not find or load main class",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37768631/

相关文章:

java - 如何在 Java DSL 中从 Camel 调用 REST 调用(POST with JSON body)

java - 指定子类的注入(inject)

Java正则表达式匹配两个连续的辅音

C# Mono Console.ReadLine 退出

scala - 如何防止Intellij将Scala警告视为错误?

java - 无法从 Google Play Android Developer API 获取订阅信息

python - python 中的 sudo renice

linux - libdbus-1.so.3 : cannot open shared object file: No such file or directory

intellij-idea - "No main manifest attribute"使用 IntelliJ IDEA 创建 Kotlin jar 时

java - v4 androidmanifest.xml 文件未找到