我的 .jar 文件无法在 java 中运行

发布于 2024-08-09 19:50:42 字数 327 浏览 2 评论 0原文

我已经创建了一个应用程序,当我通过 NETBEANS 执行它时它工作正常。

之后,我单击“清理并构建”来构建 SiteScrapper.jar 文件。现在,当我通过命令提示符调用以下 dos 命令来执行它时:

java -jar "SiteScrapper.jar"

我收到以下异常

sitescrapper.Main class not found

我的主类位于以下包中

com.innoConsulting.sitescrapper

I have created an application and it is working correctly when I am executing it through NETBEANS.

After that I had clicked on "Clean and Build" to build a SiteScrapper.jar file. Now when I am executing it through command prompt by invoking the following dos command:

java -jar "SiteScrapper.jar"

I am getting the following exception

sitescrapper.Main class not found

My Main class is located in the following package

com.innoConsulting.sitescrapper

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

旧故 2024-08-16 19:50:42

您需要检查Manifest文件中Main-Class的值。

You need to check the value of Main-Class in the Manifest file.

紫轩蝶泪 2024-08-16 19:50:42

您的 JAR 需要 META-INF/manifest.mf 说明主类所在位置的文件。

Your JAR needs a META-INF/manifest.mf file that spells out where the main class is.

爱*していゐ 2024-08-16 19:50:42

您需要包含一个清单文件。请参阅此处以获取快速说明: http://www.skylit.com/javamethods/faqs /createjar.html

You need to include a manifest file. See here for a quick explanation: http://www.skylit.com/javamethods/faqs/createjar.html

つ可否回来 2024-08-16 19:50:42

在 Netbeans 中,要么运行项目(它会要求您提供主类),要么进入项目 |属性 |运行并选择主类。

然后进行另一次清理和构建,它将生成带有适当清单文件(带有 Main-Class: set)的 JAR 文件。

In Netbeans either run the project (and it will ask you for the Main-Class) or go into the Project | Properties | Run and select the Main-Class.

Then do another clean and build and it will generate the JAR file with the appropriate manifest file (with the Main-Class: set).

○愚か者の日 2024-08-16 19:50:42

确保 jar 文件是“可执行的”。 Manifest 需要具有 Main-Class 属性。

Make sure that the jar file is 'executable'. The Manifest needs to have the Main-Class attribute.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文